总结了一些OI竞赛里要用到的快速模板,如:快读,快输等。如果有问题或补充可以评论一下
#define I inline
#define LL long long
#define W while
#define U unsigned
#define UI U int
#define ULL U LL
#define Reg register
#define RI Reg int
#define RLL Reg LL
#define C const
#define CI C int
#define CLL C LL
class FastIO{
public:
I void read(LL &x){int f=1;x=0;char ch=getchar();while(ch<‘0‘||ch>‘9‘){if(ch==‘-‘)f=-1;ch=getchar();}while(ch>=‘0‘&&ch<=‘9‘){x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}}//int快读
I void read(int &x){int f=1;x=0;char ch=getchar();while(ch<‘0‘||ch>‘9‘){if(ch==‘-‘)f=-1;ch=getchar();}while(ch>=‘0‘&&ch<=‘9‘){x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}}//long long快读
//(两个名称一样的函数放在一起,只要类型不一样,不会报错,而且这样编译器能根据输入的类型自动选择相应的函数)
I void print(int x){if(x<0)putchar(‘-‘),x=-x;if(x>9)print(x/10);putchar(x%10+‘0‘);}//int快输
I void print(LL x){if(x<0)putchar(‘-‘),x=-x;if(x>9)print(x/10);putchar(x%10+‘0‘);}//long long快输
I void printl(int x){print(x);putchar(‘\n‘);}//输出带换行
I void printl(LL x){print(x);putchar(‘\n‘);}
I LL mul(LL a,LL b,LL p){a%=p;b%=p;long long c=(long double)a*b/p;long long ans=a*b-c*p;if(ans<0) ans+=p;else if(ans>=p) ans-=p;return ans;}//快速乘
I LL Qpow(LL x,LL p,LL m){LL r=1;while(p){if(p&1LL)r=mul(r,x,m);p>>=1;x=mul(x,x,m);}return r;}//快速幂
}F;
原文:https://www.cnblogs.com/binghun/p/13829097.html