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

跟AC的代码几乎一样,只改了一点点,就WA,WA得我一头雾水,大家来看看代码哈

Posted by 123454321 at 2006-08-14 19:23:34 on Problem 1032
#include <stdio.h>
int main() 
{
	register int i,j;
	int sum,qq,n;
	
	scanf("%d",&n); 

	i=2; sum=2;
	while(sum<=n)
	{
		i++;
		sum+=i;
	}
	sum-=i;
	i--;
	qq=i;

	if(sum==n){
		printf("2");
		for(i=3;i<=qq;i++)
			printf(" %d",i);
	}
	else {
		qq++;
		j=qq-(n-sum);
		if(j==2) {
			printf("3");
			for(i=4;i<=qq;i++)
				printf(" %d",i);
		}
		else {
			printf("2");
			for(i=3;i<j;i++)
				printf(" %d",i);
			for(i=j+1;i<=qq;i++)
				printf(" %d",i);
		}
	}
	printf("\n");
	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