快速读入模板

听说 LINUX 下 isdigit() 会慢很多,自己写一个好了

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 inline bool isitdigit(char c){return  c>=‘0‘&&c<=‘9‘;}
 4 inline int readint()
 5 {
 6     register int s,f=1;register char c;
 7     while(!isitdigit(c=getchar())) (c==‘-‘)&&(f=-1);
 8     for(s=c-‘0‘;isitdigit(c=getchar());s=(s<<1)+(s<<3)+c-‘0‘);
 9     return s*f;
10 }
11 int n;
12 int main()
13 {
14     n=readint();
15     printf("%d",n);
16     return 0;
17 }

原文地址:https://www.cnblogs.com/MediocreKonjac/p/9060908.html

时间: 2024-10-17 15:07:13

快速读入模板的相关文章

C++ 快速读入 模板

原创建时间:2018-03-23 19:40:02 比HK记者还快! C++ 快速读入.输出 在 C++ 上实现快速读入模板,这里是一个读取int 的示例. inline int Quick_Read(){ int s = 0,w = 1; char ch = getchar(); while (ch <= '0' || ch > '9'){ if (ch == '-') w = -1; ch = getchar(); } while (ch >= '0' && ch &

[模板] 快速读入

//一个跟hyj巨佬学来的快速读入模板 卡常大佬不愧是卡常大佬 1 bool isdigit(char ch) 2 { 3 if(ch>='0'&&ch<='9') return 1; 4 return 0; 5 } 6 inline void fastin(int &v) 7 { 8 static char ch; 9 v=0; 10 bool p=0; 11 do 12 { 13 ch=getchar(); 14 if(ch=='-') p=1; 15 }while

卡常神器——register 与 快速读入输出

快速读入模板 int read() { int s = 0, w = 1; char ch = getchar(); //getchar() 一次从键盘读入一个字符 while (ch <='0' || ch > '9') { if (ch == '-') w = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') { s = s * 10 + ch - '0'; ch = getchar(); } return

矩阵快速幂 模板与简单讲解

模板 快速幂模板 1 void solve(matrix t,long long o) 2 { 3 matrix e; 4 5 memset(e.a,0,sizeof(e.a)); 6 7 for (int i = 0;i < d;i++) 8 e.a[i][i] = 1; 9 10 while (o) 11 { 12 if (o & 1) 13 { 14 e = mul(e,t); 15 } 16 17 o >>= 1; 18 19 t = mul(t,t); 20 } 21

51nod1113(矩阵快速幂模板)

题目链接:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1113 题意:中文题诶- 思路:矩阵快速幂模板 代码: 1 #include <iostream> 2 #define ll long long 3 using namespace std; 4 5 const int mod = 1e9+7; 6 const int MAXN = 1e2+10; 7 int n, m; 8 9 typedef struct

矩阵快速幂模板篇

转载请注明出处:http://blog.csdn.net/u012860063 或许你们看不太懂,纯属自用: 第一种: Description Let's define another number sequence, given by the following function: f(0) = a f(1) = b f(n) = f(n-1) + f(n-2), n > 1 When a = 0 and b = 1, this sequence gives the Fibonacci seq

一种简单快速的模板解析方法,活用with javascript版

//一种简单快速的模板解析方法,活用with var parseTpl = function( str, data ) { var tmpl = 'var __p=[];' + 'with(obj||{}){__p.push(\'' + str.replace( /\\/g, '\\\\' ) .replace( /'/g, '\\\'' ) .replace( /<%=([\s\S]+?)%>/g, function( match, code ) { return '\',' + code.

矩阵快速幂 模板

矩阵快速幂模板 1 #include<stdio.h> 2 #include<math.h> 3 #include<set> 4 #include<string.h> 5 using namespace std; 6 int const mod=1e9+7; 7 struct matrix 8 { 9 long long m[3][3]; 10 matrix() 11 { 12 memset(m,0,sizeof(m)); 13 } 14 matrix op

POJ 1995 Raising Modulo Numbers (快速幂模板)

Raising Modulo Numbers Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 4938   Accepted: 2864 Description People are different. Some secretly read magazines full of interesting girls' pictures, others create an A-bomb in their cellar, oth