|
|
вернуться в форумTLE on test 6!!! Послано Mik 9 июн 2006 16:04 Hello! I did everything and I don't know why I have TLE on test 6! Here is my code: {deleted} Edited by author 09.06.2006 16:13 You should stop If you read '0' Послано Alexey 10 июн 2006 00:36 Re: You should stop If you read '0' dont give loop condition within the loop as for(i=0;i<strlen(str);i++) instead int n=strlen(str); for(i=0;i<n;i++) also dont call sqrt(2) each time you evaluate x and y. e.g. Inside the loop use statement such as case 1: x-=iroot; y-=iroot; break; where iroot has been previously assigned(before the loop) sqrt(2.0)/2.0 and not case 1: x-=sqrt(2.0)/2; y-=sqrt(2.0)/2; break; Also for those who're getting compilation error in c++: call as sqrt(2.0) and not sqrt(2). One more Important thing for c++ coders. //This gives you TLE#6 string cha; cin>>cha; int n=cha.size();* int ch; for(int i=0;i<n && (ch=int(cha[i]-'0'));i++) //Whereas this gives AC char cha[1000000]; scanf("%s",cha); char f; int ch; int n=strlen(cha); for(int i=0;i<n && (ch=int(cha[i]-'0'));i++) ;) ;) Edited by author 04.12.2007 13:04 |
|
|