快速输入输出模板

template<class T> inline bool getd(T& x)
{
	int ch=getchar();
	bool neg=false;
	if(ch!=EOF && ch!=‘-‘ && !isdigit(ch)) ch=getchar();
	if(ch==EOF) return false;
	if(ch==‘-‘){
		neg=true;
		ch=getchar();
	}
	x=ch-‘0‘;
	while(isdigit(ch=getchar())) x=x*10+ch-‘0‘;
	if(neg) x=-x;
	return true;
}

template<class M> inline void putd(M x)
{
	int p=0;
	if(x<0){
		putchar(‘-‘);
		x=-x;
	}
	do{
		buf[p++]=x%10;
		x/=10;
	}while(x);
	for(int i=p-1;i>=0;i--) putchar(buf[i]+‘0‘);
	putchar(‘\n‘);
}
时间: 2024-07-29 00:52:46

快速输入输出模板的相关文章

模板 - 快速输入输出

非负整数的快速输入输出 inline int read(){ int x=0; char c=getchar(); while(c<'0'||c>'9') c=getchar(); do{ x=(x<<3)+(x<<1)+c-'0'; printf("x=%d\n",x); c=getchar(); }while(c>='0'&&c<='9'); return x; } inline void write(int x){

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

模板 快速幂模板 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

快速幂和矩阵快速幂模板

快速幂模板: ll qmod(ll x,ll n,ll mod) { ll res=1; while(n){ if(n&1) res=(res*x)%mod; x=(x*x)%mod; n/=2; } return res; } 例题:hdu 1097 #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<cmath> usin

HDU1575--Tr A(矩阵快速幂模板)

Tr A Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Description A为一个方阵,则Tr A表示A的迹(就是主对角线上各项的和),现要求Tr(A^k)%9973. Input 数据的第一行是一个T,表示有T组数据. 每组数据的第一行有n(2 <= n <= 10)和k(2 <= k < 10^9)两个数据.接下来有n行,每行有n