| ||||||||||
| 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 | |||||||||
wa了。。。附代码#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator