| ||||||||||
| 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 | |||||||||
100b不到的代码怎么写的,怎么都写不到200以下#include<iostream>
#include<cmath>
using namespace std;
int main()
{
int t,a,ans;
while(cin>>t&&t)
{
a=(sqrt(t*2));
if(((1+a)*a/2)>t)a--;
ans=a*(a+1)*(2*a+1)/6+(t-(1+a)*a/2)*(a+1);
cout<<t<<" "<<ans<<endl;
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator