Общий форумXot kto nibud, skajite, chto takoe sluchaet test13 It is possible to get AC with a 10-lines program. Simply use regular expressions: Q = "(?<!\\\\)\"" for " which is not preceded by \ ".*?(?:\n\r?\n|\\\\par(?![A-Za-z])|$)" for paragraph (note \r) For each paragraph you get with Scanner.findWithinHorizon, do replaceAll matching Q+"(.*?)"+Q with "``$1''" and then replaceFirst Q with an empty string. Btw, the real TeX parsing is much more complicated, e.g., \\par would not end a paragraph. I passed test 3 after replacing my "blank line" regexp "\n\n" with "\n\r?\n". Apparently "blank" (which used to mean "empty") here means empty or "\r". Alexander Akimenko ssau 6108 test [1] // Задача 1273. Шпалы 21 мар 2010 15:37 please give some tests, WA7 I've check all the data here..but i still get WA#12.. #include <iostream> #include <cstring> #include <string> #define inf 214748364 using namespace std; struct tmono { int n[9000]; int w,nega,xs; }; char s[1000]; int xs,len,con,e; tmono num; string res; inline bool isnum(char ch) { return '0'<=ch&&ch<='9'; } inline bool getnum(int st,int en,tmono &e) { memset(e.n,0,sizeof(e.n)); e.w=0;e.xs=0;e.nega=0; if(s[st]=='-') e.nega=1,++st; else if(s[st]=='+') e.nega=0,++st; /* while(s[st]=='+'||s[st]=='-') { if(s[st]=='-') e.nega=!e.nega; ++st; } */ for(int i=en;i>=st;i--) if(s[i]=='.') { e.xs=en-i; for(int j=i;j<en;j++) s[j]=s[j+1]; --en; break; } for(int i=st;i<=en;i++) if(!isnum(s[i])) return 0; e.w=0; for(int i=en;i>=st;i--) e.n[++e.w]=s[i]-'0'; return 1; } inline bool work() { res=""; cin>>xs; int tempxs=xs; scanf("\n"); if(s[0]=='.') { for(int i=len-1;i>=0;i--) s[i+1]=s[i]; s[0]='0'; len++; } if(!isnum(s[0])&&s[0]!='-'&&s[0]!='+') return 0; con=0; for(int i=0;i<len;i++) { if(s[i]=='e'||s[i]=='E') { if(con!=0) return 0; con=i; } if(s[i]!='e'&&s[i]!='E'&&s[i]!='-'&&s[i]!='+' &&s[i]!='.'&&!isnum(s[i])) return 0; if(s[i]=='.'&&!isnum(s[i+1])) return 0; } e=0; bool enega=0; if(con!=0) { e=-inf; int j=con; con++; if(s[con]=='+'||s[con]=='-') { if(s[con]=='-') enega=!enega; con++; } /* while(s[con]=='-'||s[con]=='+') { if(s[con]=='-') enega=!enega; ++con; }*/ for(int i=con;i<len;i++) { if(!isnum(s[i])) return 0; if(e==-inf) e=0; e=e*10+s[i]-'0'; if(e>500) break; } if(e==-inf) return 0; if(enega) e*=-1; len=j; } --len; if(!getnum(0,len,num)) return 0; num.xs-=e; while(num.n[num.w]==0&&num.w>0) --num.w; bool isxs=0; if(num.xs<=0) { for(int i=num.w;i>=1;i--) res+=num.n[i]+'0'; while(num.xs<0) { res+="0"; num.xs++; } }else { int j=max(num.w,num.xs); if(num.xs>num.w) { num.w=num.xs; num.xs=0; res+="0."; isxs=1; } for(int i=j;i>=1;i--) { if(i==num.xs) isxs=1; if(isxs&&xs==0) break; if(i==num.xs) res+="."; if(isxs)--xs; res+=num.n[i]+'0'; } } while(xs>0) { if(!isxs) res+=".",isxs=1; res+="0",--xs; } while(res[0]=='0') res.erase(0,1); if(res.length()==0) res.insert(0,"0"); if(res[0]=='.') res.insert(0,"0"); for(int i=0;i<res.length();i++) if(res[i]=='.') if(res.length()-i<tempxs) { tempxs-=res.length()-i; while(tempxs--) res.insert(res.length()-1,"0"); }else res.erase(i+tempxs,res.length()-i-tempxs-1); if(res[res.length()-1]=='.') res.erase(res.length()-1,1);
if(num.nega) for(int i=0;i<res.length();i++) if('1'<=res[i]&&res[i]<='9') { res.insert(0,"-"); break; } for(int i=1;i<res.length();i++) if(res[i]=='.'&&!isnum(res[i-1])) { res.insert(i,"0"); break; } if(res[res.length()-1]=='.') res.erase(res.length()-1,1);
res+="\n"; return 1; } inline void reads() { memset(s,0,sizeof(s)); gets(s); len=strlen(s); while(len>=1&&isspace(s[len-1])) s[len]=0,--len; while(isspace(s[0])) { for(int j=0;j<len-1;j++) s[j]=s[j+1]; s[len]=0;len--; } } int main() { #ifndef ONLINE_JUDGE freopen("input.in","r",stdin); freopen("output.out","w",stdout); #endif reads(); while(!(strlen(s)==1&&s[0]=='#')) { if(!work()) printf("Not a floating point number\n"); else cout<<res; reads(); } return 0; } Check that: S12.0 2 # where S is a space (" "). My AC program says that its not a correct number because of leading space. "For each pair of lines your program should write to an output a message: "Not a floating point number", if the string S is not a correct <real number>..." <real number> does not contain spaces. =) Good luck! Many thanks!!!really a helpful suggest! now I got AC. thanks again! Edited by author 23.03.2010 05:23 NOT FLOATING FOR 1)1E2.1 2)2E2+1 3)2E2-1 4)E 5)-+3 6)3EE ----------------------------------------- 1) 1E1 1 10.0 1E+1 1 10.0 0E10 1 0.0 0 1 0.0 000.1 1 0.1 0.1E1 0 1 why"-+3" isn't a correct number.? Is my greedy algo correct? On each step I choose an edge to vertex with the greatest out-degree. I have WA 8. Of course, you should find Euler cycle I know AC solution that counts number of cw and ccw moves from point i to i+1 seen from the first point. Here is the test on which this AC solution answers cw but correct answer is ccw. 17 0 0 10 0 10 10 11 10 11 9 11 8 11 7 11 6 11 5 11 4 11 3 11 2 11 1 11 0 12 0 12 11 0 11 I'm agree with you. Edited by author 22.03.2010 08:38 I'm sorry. I find my mistake/ I don't understand this problem. As I think, the third sample is the tree from the picture. But I can not understand why, for example, 'the number of the ancestor of this node' for the node #18 is 12? What does it mean, 'the number of the ancestor of this node'? THank you. As you can see in a picture, the node #18 connected with the #12 node, and - #18 is a child for #12; - #12 is a ancestor, farther (mother) of #18. In phrase "the number of the ancestor of this node" the word "number" should be understood ad index (the index of the node, which is an ancestor for target node). small a, big b, big n, and the LCM of a and b is larger than n. such as 3 24999998 25000000 Edited by author 21.03.2010 23:41 I have written 2 programs and both get WA19 It is very strange, I am already tired to write programs to this problem. first 2*BFS secondar Dijkvasta+Heap both got Wa19 i not understand why. Somebody help me? hi I don't understand in english. hwo can explain this question in Azeri or Turkish or in english but with sample sentenceses you just need to do 2 BFS Edited by author 22.03.2010 02:04 Edited by author 22.03.2010 02:04 there is my program var c:array[0..1800] of real; n,m,i ,fn:longint; begin readln(n,m); c[0]:=1; c[1]:=m-1; i:=1; repeat i:=i+1; {for i:=2 to n do } c[i]:=(m-1)*(c[i-1]+c[i-2]); until i>=n; writeln(c[n]:0:0); end. Because There is some testcases that have more than 1800 decimal digits.You should write Big int for this problem. My AC program runs about 10 seconds on following tests; 4 41 4 49 (on this test it works more, that 1 minute!!!) 17 43 19 49 41 43 50 41 50 43 I can write about 10 more tests, but, I think, it's enough:) Could you add some of these tests? Your tests were added, and problem was rejudged. Thank you. Here is my code, what can make my code run faster? Please check it up... #include <iostream> #include <cmath> using namespace std; bool prime(long long x) { int i;
if(x==2) return true; else if(x%2==0) return false;
for(i=3; i*i<=x; i+=2) if(x%i==0) return false; return true;
} int main() { long long K, s;
cin>>K; if(prime(K)==true) { cout<<K-1; return 0; } else { for(long long i=3; i<499999950; i++) { if(K%i==0) { cout<<i-1; return 0; } } } return 0; } Функция Prime может быть встроена в main Вместо if(Prime(K)==true) можно писать if(Prime(K)) oh my... =) This lazy code gets AC in 0.562s #include <cstdio> int n,r; int main() { .scanf("%d", &n); .r=2; .while ( n % (r+1) != 0 ) ..++r; .printf("%d",r); .return 0; } And this a little bit (only a little) improved, especially for you, gets AC in 0.296s. #include <cstdio> int n,r; int main() { .scanf("%d", &n); .if ( n % 3 == 0 ) .printf("2"); .else if ( n % 4 == 0 ) ..printf("3"); .else .{ ..r=4; ..while ( n % ++r != 0 ) ...++r; ..printf("%d",r-1); .} .return 0; } Hope this test can help you: 2 3 2 1 0 1 0 - NO YES Good luck! why my program doesnot work on WA#2???? var a:array [1..10000] of integer; i,k,s:integer; begin k:=0; s:=1; for i:=1 to 10 do readln(a[i]); for i:=1 to 10 do s:=s*a[i]; for i:=1 to s do if s mod i=0 then k:=k+1; if (k>0)and (k<10) then writeln(k); end. Edited by author 21.03.2010 05:16 I can't find a mistake in my solution. Can anybody give me any hint? #include <cstdlib> #include <iostream> #include <iomanip> using namespace std; int main(int argc, char *argv[]) {
double a,b,c,d,m,n=2,mn; cin>>a>>b; c=a/100; d=b/100; while (1) {m=1; while (m<n) {mn=m/n; if ((mn<d)&&(mn>c)) break; m++;} if (m!=n) break; n++;} cout<<n<<endl; system("PAUSE"); return EXIT_SUCCESS; } This is my project Got WA on test14. I think there's something wrong with digits But i cannot find it Can anyone help me with it? Thx! I think, your mistake in precision. Try change: if ((mn<d)&&(mn>c)) -> if ((mn+eps<d)&&(mn-eps>c)) I used "dp" and spend 261k space and 0.046 time, but i see the rank 1 only used 0.015 second?
How did he make it? |
|