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

用了n多数据都真确为什么WA?

Posted by lhzlucky at 2006-12-19 18:46:50 on Problem 2602
#include <iostream>
using namespace std;
void main()
{
	int i,num=0,n,a,b,t=-1,k;
	cin>>n;
	while(n--)
	{
		cin>>a>>b;
        k=a+b;
		if(k<9)
		{
			if(t!=-1)
			cout<<t;
			if(num)
			{
				for(i=0;i<num;i++)
				cout<<9;
				num=0;
			}
			t=k;
			if(n==0)cout<<t;
		}
		else if(k==9)
		{
			if(t==-1)t=k;
			if(n)num++;
			else 
			{
				cout<<t;
				for(i=0;i<num+1;i++)
				cout<<9;
			}
		}
		else
		{
			t++;
			cout<<t;
			if(num)
			{
				for(i=0;i<num;i++)cout<<0;
				num=0;
			}
			t=k%10;
			if(n==0)cout<<t;
		}
	}
	cout<<endl;
}

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