|
|
back to boardWA26 This is my code: #include <stdio.h> #include <string.h> #define ulong unsigned long void main() { #ifndef ONLINE_JUDGE freopen("in.txt","rt",stdin); freopen("out.txt","wt",stdout); #endif bool comment=0,arithmetical=0; long brakets=0; char syms[10001]; ulong i=0; while(fgets(syms+i,10000,stdin)) { i=strlen(syms)-1; } for(i=0;i<strlen(syms);++i) { if(comment) { for(;i<strlen(syms);++i) if(syms[i]=='*'&&syms[i+1]==')') { ++i; comment=0; break; } continue; } if(arithmetical) { for(;i<strlen(syms);++i) { if(!((syms[i]>=0x28&&syms[i]<=0x2B)||(syms[i]>=0x30&&syms[i]<=0x39)||syms[i]=='-'||syms[i]=='/'||syms[i]=='=')) { printf("NO"); return; } if(syms[i]=='(') { if(syms[i+1]=='*') { ++i; comment=1; break; } ++brakets; } if(syms[i]==')') { --brakets; if(!brakets) { arithmetical=0; break; } } } continue; } for(;i<strlen(syms);++i) { if(syms[i]=='(') { if(syms[i+1]=='*') { ++i; comment=1; break; } ++brakets; arithmetical=1; break; } if(syms[i]==')') { printf("NO"); return; } } } if(comment||arithmetical) { printf("NO"); return; } printf("YES"); } why wa 26? Re: WA26 (*(**)*) must be "YES" or "NO"? Re: WA26 must be "NO". i find the mistake.it seems, test contains the limit of text in one line. Edited by author 25.06.2011 17:34 Edited by author 25.06.2011 17:35 |
|
|