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

开500000不能运行,开小了又不合题意,怎么办呢?

Posted by zzzzzz at 2004-11-26 11:24:13 on Problem 2081
#include<stdio.h>
void main()
{
	int a,j,n;long int sum[500000];
	scanf("%d",&n);
	while(n!=-1)
	{
	sum[0]=0;
	for(a=1;a<=n;a++)
	{
		if(sum[a-1]-a>0) 
		{
			for(j=1;j<a;j++)
			{
				if(sum[a-1]-a!=sum[j])          
				continue;
				sum[a]=sum[a-1]+a;
				goto loop;
			}
			sum[a]=sum[a-1]-a;
		     
		}
    loop:  if(sum[a-1]-a<=0) sum[a]=sum[a-1]+a;
	}
 	printf("%d\n",sum[n]);
	scanf("%d",&n);
	}
}
 

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