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

为什么wrong answer?

Posted by jjjyyy at 2006-01-05 21:05:02 on Problem 2000
#include<stdio.h>
#include<math.h>
void main(){
	int i,n,sum,sum1=0;
	for(;;){
		scanf("%d",&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;
			}
		}
		printf("%d %d\n",n,sum1);
	}
}



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