| ||||||||||
| 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 | |||||||||
Re:这不是真的把?有那么复杂吗?我的程序Memory: 204K Time: 0MSIn Reply To:呵呵,只要考虑清楚了,用一个数组就搞定了,175ms搞定。好高兴了! Posted by:RMJ87 at 2008-04-18 22:04:31 Source Code
Problem: 2000 User: hustzh
Memory: 204K Time: 0MS
Language: C++ Result: Accepted
Source Code
#include <cstdio>
int main()
{
int d;
int s1,s2,i;
while(scanf("%d",&d) != EOF,d)
{
for(s1 = s2 = 0,i = 1;s2 < d;i ++)
{
s1 += i*i;
s2 += i;
}
if(d != s2)
s1 += (d-s2)*(i-1);
printf("%d %d\n",d,s1);
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator