| ||||||||||
| 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:真是服了 cout 和printf换换样就不对了 c++又不支持cout<<了吗?真是的In Reply To:真是服了 cout 和printf换换样就不对了 c++又不支持cout<<了吗?真是的 Posted by:0712105003 at 2009-10-16 14:25:20 #include<stdio.h>
int main()
{
int n;
int i=0;
int sum,count;
int result;
while(scanf("%d",&n)!=EOF)
{
i=0;
sum=0;
count=0;
if(n==0) break;
do
{
i++;
sum+=i;
count+=i*i;
if(sum==n)
{
result=count;
}
else
result=count+(n-sum)*i;
}while(sum<n);
printf("%d %d\n",n,result);
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator