准备CSP 复赛
用来方便自己复习
版本C++14
快读和快输
链接:
打的时候一定要注意运算符优先级QWQ(有时候真的很难发现)
错误示例:
int read() { static int x,f; static char ch; x=f=0; while(!isdigit(ch=getchar()) ) if(ch=='-') f=!f; while(isdigit(ch)) x=(x<<3)+(x<<1)+ch&15,ch=getchar(); if(!f) return x; else return -x; }
原因: 加法的优先级高于按位与……
正常代码:
const int L=1<<20; char buf[L],*p1=buf,*p2=buf; #define getchar() (p1==p2 && (p2=(p1=buf)+fread(buf,1,L,stdin),p1==p2)?EOF:*p1++) int read() { static int x,f; static char ch; x=f=0; while(!isdigit(ch=getchar()) ) if(ch=='-') f=!f; while(isdigit(ch)) x=x*10+(ch&15),ch=getchar(); if(!f) return x; else return -x; }
小数据(scanf
快点
注意事项
链接:
缺省源
//减少码量的 #define rep(i,st,n) for(int i=(st);i<=(n);++i) #define _rep(i,st,n) for(int i=(st);i<(n);++i) #define dwh(i,st,n) for(int i=(st);i>=(n);--i) #define _dwh(i,st,n) for(int i=(st);i>(n);--i) //快读快输... //... //还是想cin的 #define FAST_IO ios::sync_with_stdio(0),cin.tie(0) //max() and min() int max(int x,int y){return x>y?x:y;} int min(int x,int y){return x<y?x:y;} int bmax(int &x,int y){return x=max(x,y);} int bmin(int &x,int y){return x=min(x,y);}
对拍
编译器选项
链接:
编译器选项加入:
-Wl,--stack=536870912 -std=c++14 -lm -Wall
解释:
-Wl,
可用于查找一些编译器编译时无法查出的问题,如scanf("%d",a)
-Wl,--stack=SIZE
把栈的空间限制为SIZE byte(536870912 byte=512MB)-std=c++14
按照c++14的标准编译-Wall
打开"显示最多警告信息"
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步