Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Re:uva的题目比较重基本功吧In Reply To:Re:uva的题目比较重基本功吧 Posted by:hongyan at 2005-10-19 09:04:12 我和你相反,uva上面A,这里WA,谢谢你的程序.我的: #include <iostream> #include <math.h> #include <string> using namespace std; int main() { long len,i,sum,lev,cnt,cp,f,st[10000]; char temp; while (scanf("%d",&len)!=EOF) { lev=sum=cnt=cp=f=0; while (1) { while ((temp = getchar())!='(') { if (temp==')') { f++; if (f==4) { if (sum==len) cp = 1; } sum-=st[lev--]; } if (!lev) { if (f) goto a; } } lev++; f++; if (scanf("%d",&i)) { st[lev]=i; sum+=i; f=0; continue; } else { st[lev]=0; while ((temp = getchar())!=')'); f++; if (f==4) { if (sum==len) cp=1; } sum-=st[lev--]; } a: if (!lev) { if (cp) { fflush(stdin); printf("yes\n"); cp=0; break; } else { fflush(stdin); printf("no\n"); } break; } } } return (0); } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator