【求助】问题
Online Judge Problem Set Authors Online Contests Exercise Author Home Page
Notification
F.A.Q
Forum
Administration Problem Archive
Submit Solution
Realtime Judge Status
Register New Author
Update Your Information
Authors Ranklist
Next Contest Time
2008-12-20 12:30:00 (GMT+8)
Scheduled Contests
Passed Contests
DIY Contests ! chenjian
Mail 0(0)
Write New Mail
Sign Out
View Code
Problem : 2041 ( 超级楼梯 ) Judge Status : Time Limit Exceeded
RunId : 858096 Language : C++ Author : chenjian880514
Code Render Status : Rendered By HDOJ C++ Code Rander Version 0.01 Beta
#include<stdio.h>
__int64 a[50];
int main()
{
int n,i;
a[0]=0;
a[1]=1;
a[2]=2;
a[3]=3;
a[4]=4;
a[5]=6;
a[6]=9;
for(i=7;i<=55;i++)
a[i]=a[i-1]+i-3;
while(scanf("%d",&n)!=0)
{
printf("%I64d\n",a[n]);
}
}
#include<stdio.h>
__int64 a[50];
int main()
{
int n,i;
a[0]=0;
a[1]=1;
a[2]=2;
a[3]=3;
a[4]=4;
a[5]=6;
a[6]=9;
for(i=7;i<=55;i++)
a[i]=a[i-1]+i-3;
while(scanf("%d",&n)!=0)
{
printf("%I64d\n",a[n]);
}
}
题目要求,n=0表示输入数据的结束,不做处理。
而我的遇0时好像只是不处理,但输入没有结束,我的想法对吗?那程序应该怎样修改呢