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

wrong 为什么,,各种测试数据都行,还是错,,

Posted by 201358501108 at 2014-07-31 13:02:27 on Problem 1145
#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:
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