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

拙码,分享之

Posted by wanderboy at 2011-02-09 23:06:01 on Problem 1032
#include <stdio.h>
#include <math.h>

int main(int argc, char *argv[])
{
	int n,i,sum,init=2,t=0;
	scanf("%d",&n);
	i=sqrt(n*2.);
	sum=(i*i+3*i)/2;
	while((sum-=i+1)>n)--i;
	n-=sum;
	--i;
	init+=n/i;
	n%=i;
	while(t++<i-n)printf("%d ",init++);
	++init;
	while(n--)printf("%d ",init++);
	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