Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:uva的题目比较重基本功吧

Posted by pyh119 at 2008-11-29 12:49:03 on Problem 1145
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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator