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 |
考虑负数In Reply To:wrong 为什么,,各种测试数据都行,还是错,, Posted by:201358501108 at 2014-07-31 13:02:27 > #include <iostream> > #include <stdio.h> > #include <string> > #include <string.h> > using namespace std; > int a[10000],count ; > string s; > char te; > int main() > {int n; > > while(cin>>n) > {s=""; > memset(a,0,sizeof(a)); > int pan=0; > while(cin>>te) > {s+=te; > if(te=='(')pan++; > else if(te==')')pan--; > if(pan==0)break; > } > > > bool p=0; > int i=0,t=0; > count=0; > while(i<s.length()) > { > > if(s[i]=='(') > {i++; > if(s[i]==')')i++; > else { > > > if(s[i]=='-'){i++; > while(s[i+1]!='('&&s[i+1]!=')') > {a[t]=int(s[i]-'0'); > a[t]=a[t]*10; > i++; > } > > a[t]+=int(s[i]-'0'); > i++; > count-=a[t]; > } > else{ > while(s[i+1]!='('&&s[i+1]!=')') > {a[t]=int(s[i]-'0'); > a[t]=a[t]*10; > i++; > } > > a[t]+=int(s[i]-'0'); > i++; > count+=a[t]; > > } > > > t++; > > } > > } > if(s[i]==')') > { if(count==n&&s[i-4]=='('){ > cout<<"yes"<<endl; > p=1; > break;} > > t--; > count-=a[t]; > i++; > a[t]=0;} > > } > > if(p==0)cout<<"no"<<endl; > } > > > return 0;} Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator