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是Runtime Error,改小些是wrong answer;在VC上开500000是要发送错误报告,改小些是能输出正确答案

Posted by zzzzzz at 2004-11-26 12:39:41 on Problem 2081
In Reply To:开500000不能运行,开小了又不合题意,怎么办呢? Posted by:zzzzzz at 2004-11-26 11:24:13
> #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