| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
开500000不能运行,开小了又不合题意,怎么办呢?#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator