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 juventus at 2008-02-06 00:34:48 on Problem 1032
#include <iostream>
using namespace std;
void main()
{
	int N;
	cin>>N;
	int i=2;
	while (i*(i+1)/2-1<=N) i++;
	int w=i-1;//序列末尾
	int sum=w*(w+1)/2-1;
	if (N-sum==w)//恰好相等,都加1
	{
		for (i=3;i<=w;i++) cout<<w<<' ';
		cout<<w+2<<endl;
	}
	else//直到不能加为之
	{
		i=w+1-N+sum;
		int j;
		for (j=2;j<=i-1;j++) cout<<j<<' ';
		for (j=i+1;j<=w+1;j++) cout<<j<<' ';
		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