| ||||||||||
| 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 | |||||||||
数学问题……考虑清楚了就好了……
直接贴代码……
Source Code
Problem: 2000 User: shr1992
Memory: 132K Time: 0MS
Language: C++ Result: Accepted
Source Code
#include<iostream>
using namespace std;
int main()
{
int n,i,x=0;
scanf("%d",&n);
while(n!=0){
for(i=1;i<=n;i++){
if(n==i*(i+1)/2){
x=i*(i+1)*(2*i+1)/6;
break;
}
if(n<i*(i+1)/2){
x=i*(i-1)*(2*i-1)/6+i*(n-i*(i-1)/2);
break;
}
}
printf("%d %d\n",n,x);
scanf("%d",&n);
x=0;
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator