输入优化
void gi(int & a) { char t = getchar(); a = 0; for(; !isdigit(t); t = getchar()); for(; isdigit(t); a *= 10, a += t - 48, t = getchar()); } void gc(char & t) { t = getchar(); for(; !isalpha(t); t = getchar()); } void gs(string &s){ char t; s = ""; for(t=getchar(); !isprint(t);t=getchar()); for(; isprint(t); s+=t, t=getchar()); } void read(int &x) { int f=1; x=0; char s=getchar(); while(s<'0'||s>'9') { if(s=='-')f=-1; s=getchar(); } while(s>='0'&&s<='9') { x=x*10+s-'0'; s=getchar(); } x*=f; }
测试运行时间
#include <ctime> clock_t start=clock(); cout<<(double)(clock()-start)/CLOCKS_PER_SEC<<endl;
本作品使用基于以下许可授权:Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.