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没想到一次AC

Posted by power721 at 2009-10-13 22:19:33 on Problem 1032
#include<stdio.h>
#include<math.h>
main()
{int n,i,s,sum=0,a[50];
scanf("%d",&s);
n=(sqrt(8*s+9)-1)/2;
for(i=2;i<=n;i++)
	a[i]=i;  
for(i=2;i<=n;i++)
	sum+=a[i];
while(sum<s)
	{--i;
	if(i<2)i=n;
	a[i]++,sum++;
	}
for(i=2;i<=n;i++)
	printf("%d ",a[i]);
puts("");
}

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