|
|
back to boardPLEASE TELL ME WHY TLE? #include <iostream> #include <algorithm> #include <string> #include <cctype> #include <iomanip> #include <cmath> using namespace std; #define MaxN 500000 #define f0(i,n) for(i=0;i<n;i++) #define f1(i,n) for(i=1;i<n;i++) char x[MaxN]; int main() { int i=0; char c; while((c=getchar())!='\n') { x[i]=c; i++; } long int total=0,t=1; int j,k,l,m; m=i; int count=0; int counter; f1(i,MaxN) { if(i<10 && i>=0)t=1; if(i<100 && i>=10)t=2; if(i<1000 && i>=100)t=3; if(i<10000 && i>=1000)t=4; if(i<100000 && i>=10000)t=5; f0(j,m) { total=0; counter=1; for(k=j;k<j+t;k++) { l=x[k]-48; total+=pow(10,t-counter)*l; counter++; } if(total==i) { count++; break; } } if(count==0) { cout<<i<<endl; break; } count=0; } return 0; } Thanks!!! |
|
|