Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:100题留念,有此里程碑,将一如既往!!!^_^

Posted by Lesliezhang at 2014-07-05 22:04:18 on Problem 2000
In Reply To:Re:100题留念,有此里程碑,将一如既往!!!^_^ Posted by:vltam1n at 2009-12-17 11:04:22
> hehehe.
#include<iostream>
using namespace std;
int main()
{
double  n,j;
while (cin>>n&&n!=0)
{  double  s=0,i=1,t=0;
   for(i=1;;i++)
   {
    if(i*(i+1)<=2*n)
     {
          if(i*(i+1)==2*n)
           break;
     }
    else if(i*(i+1)>2*n&&(i*(i-1)<2*n))
     {   double  m;
           i--;
         m=i*(i+1)/2;
         t=n-m;
         break;
     }
   }
   if(t==0)
    {
       for(int j=1;j<=i;j++)
        s=s+j*j;
    }
    else if(t!=0)
     {
        for(int j=1;j<=i;j++)
            s=s+j*j;
            s=s+t*(i+1);
     }
 cout<<n<<" "<<s<<endl;}
 return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator