stick(实用)
将f复制到g中
int f[100300];
int g[100300];
for(int i=2;i<=200;i++) cin>>f[i];
memcpy(g,f,sizeof(f));
快读
极简8行
int read()
{
int num=0;bool flag=1;
char c=getchar();
for(;c<'0'||c>'9';c=getchar())
if(c=='-')flag=0;
for(;c>='0'&&c<='9';c=getchar())
num=(num<<1)+(num<<3)+c-'0';
return flag?num:-num;
}
另一个快读
更强大的读入优化
struct ios{
inline char read(){
static const int IN_LEN=1<<18|1;
static char buf[IN_LEN],*s,*t;
return (s==t)&&(t=(s=buf)+fread(buf,1,IN_LEN,stdin)),s==t?-1:*s++;
}
template <typename _Tp> inline ios & operator >> (_Tp&x){
static char c11,boo;
for(c11=read(),boo=0;!isdigit(c11);c11=read()){
if(c11==-1)return *this;
boo|=c11=='-';
}
for(x=0;isdigit(c11);c11=read())x=x*10+(c11^'0');
boo&&(x=-x);
return *this;
}
}io;
卡常快读
#define SIZE (1<<20)
char in[SIZE],out[SIZE],*p1=in,*p2=in,*p3=out;
#define getchar() (p1==p2&&(p2=(p1=in)+fread(in,1,SIZE,stdin),p1==p2)?EOF:*p1++)
inline int read()
{
int x=0,f=1;char ch=getchar();
while(ch<48||ch>57){if(ch=='-')f=-1;ch=getchar();}
while(ch>=48&&ch<=57) x=(x<<3)+(x<<1)+ch-48,ch=getchar();
return x*f;
}
inline void write(int x)
{
if(x<0) putchar('-'),x=-x;
if(x>9) write(x/10);
putchar((x%10)^48);
}
快速输出
void write(int x)
{
if(x<0)putchar('-'),x=-x;
if(x>9)write(x/10);
putchar((x%10)^48);
}//快写
关闭流同步
std::ios::sync_with_stdio(false);
神仙速乘
inline LL mul(LL a,LL b,LL mod)
{
LL A=a*(b>>30ll)%mod*(1ll<<30)%mod;
LL B=a*(b&((1ll<<30)-1))%mod;
return (A+B)%mod;
}//
关键字冲突列表
random
y2
next
tube
hash
yn
time
next
random
取模运算代码
inline int add(int a,int b,int p=mod){return a+b>=p?a+b-p:a+b;}
inline int sub(int a,int b,int p=mod){return a-b<0?a-b+p:a-b;}
int mul(int a,int b,int p=mod){return (LL)a*b%p;}
void sadd(int &a,int b,int p=mod){a=add(a,b,p);}
void ssub(int &a,int b,int p=mod){a=sub(a,b,p);}
void smul(int &a,int b,int p=mod){a=mul(a,b,p);}
本文来自博客园,作者:whrwlx,转载请注明原文链接:https://www.cnblogs.com/whrwlx/p/18077310