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:看一下哦

Posted by tom20511 at 2007-05-23 19:38:41 on Problem 2000
In Reply To:看一下哦 Posted by:uestczhangchao at 2007-05-23 10:52:36
> 
> #include<iostream>
> using namespace std;
>  #include<math.h>
> int main(){
>      int i,j,n,sum;  int sum1=0;int k=0;
> 	 int a[50],b[50];
> 	for(;;)
> 	{
> 	    cin>>n;
>  		if(n==0) break;
>  		sum=0;
>  		for(i=1;i<n;i++)
> 		{
>  		   sum=sum+i*i;
>  			if(n==(i*i+i)/2)
> 			sum1=sum;
> 
>  	  	   else if(n>(i*i-i)/2&&n<=(i*i+i)/2)
>  				sum1=sum-((i*i+i)/2-n)*i;
>  			
>  		}
> 	a[k]=n;
> 	b[k]=sum1;
> 	k++;
>  	}
> 	for(j=0;j<k;j++)
> 	{cout<<a[j]<<" "<<b[j]<<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