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:大牛们帮忙看看,为什么老wa呢?

Posted by zgalss at 2007-07-15 09:39:32 on Problem 2000
In Reply To:大牛们帮忙看看,为什么老wa呢? Posted by:DH_FireCity at 2006-02-25 12:54:19
> #include<iostream.h>
> void main(){
> 	int day;
> 	while(cin>>day){
> 		int k,t;
> 		long int total=0;
> 		k=1;
> 		while((k*(k+1)/2)<day){
> 			k++;
> 		}
> 		t=k*(k+1)/2;
> 		if(t>day){k=k-1;};
> 		t=day-((k*(k+1))/2);
> 		int i;
> 		for(i=1;i<=k;i++){
> 			int j;
> 			for(j=1;j<=i;j++){
> 				total=total+i;
> 			}
> 		}
> 		total=total+(k+1)*t;
>         cout<<day<<' '<<total<<endl;
> 	}
> 	
> }

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