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

高手帮帮忙阿~简单的代码,测试数据都过了,就是wa~~~~~

Posted by windkui at 2008-08-04 11:08:27 on Problem 1032
#include<iostream>
using namespace std;
int main()
{
	long i,j,a,b(0),k,c[1001];
	while(cin>>a)
	{
		for( i = 2; b <= a; i++ )
		{
			b+=i;
			c[i]=i;		
		}
		c[i]=i;
		j=i;
		if( b==a )
		{
			for( i=2; i < j; i++ )
				cout<<c[i]<<'\0';
		}
		else
		{
			if( b - a == 1 )
			{
				for( i = j; i > 2; i-- )
					if( b + j - 2 - i == a )
					{
						k=i;
						break;
					}
					for( i = 3; i < k; i++ )
						cout<<c[i]<<'\0';
					for( i = k + 1; i < j + 1; i++ )
						cout<<c[i]<<'\0';
					cout<<endl;
			}
			else
				{
					for( i = 2; i < b - a; i++ )
						cout<<c[i]<<'\0';
					for( i = b - a + 1; i<j ; i++ )
						cout<<c[i]<<'\0';
					cout<<endl;
				}
		}
		b=0;
	}

	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