怎么写怎么错 各种坑 - -
最后发现 int 爆了..爆的很有水平
改好以后准备交..弹出了 "hack time!" time..time..
9099999999
-1000000000 1000000000
92233720368547758080
-1000000000 1000000000
第一组数据是用来爆int的
第二组是用来爆longlng的
好吧..得提前检测长度..
对了..程序拿加速输入改的
看了别人的还有用sscanf和sprintf 再strcmp的 这个比较diao
#include <cstring> #include <algorithm> #include <cstdio> #include <cctype> using namespace std; inline bool scan_d(char *s,long long &ret,int a,int b) { char c; int sgn; c=*s++; if(c!='-'&&(c<'0'||c>'9')) return 0; sgn=(c=='-')?-1:1; ret=(c=='-')?0:(c-'0'); if(!ret&&c!='-'&&*s) return 0; while(c=*s++) { if(ret==0&&c=='0') return 0; //printf("return %d %c\n",ret,c); if(!(c>='0'&&c<='9')) return 0; ret=ret*10+(c-'0'); //printf("%lld\n",ret); if(ret>1e9) return 0; } ret*=sgn; if(ret>b||ret<a) return 0; if(sgn==-1&&ret==0) return 0; return 1; } char str[200],num[200]; int main() { //freopen("b.in","r",stdin); while(gets(str)!=NULL) { int a,b; long long c; gets(num); sscanf(num,"%d%d",&a,&b); if(scan_d(str,c,a,b)) puts("YES"); else puts("NO"); } return 0; }