| ||||||||||
| 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 | |||||||||
为什么超过时间限制???#include <stdio.h>
int main()
{
while(1)
{
int flag,ans=0;
scanf("%d",&flag);
if(flag==0) continue;
else
{
int i;
for(i=1;i*(i+1)/2<=flag;i++){}
ans=(i-1)*i*(2*i-1)/6+i*(flag-(i*(i-1))/2);
}
printf("%d %d\n",flag,ans);
}
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator