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 flyagain at 2006-03-07 22:27:09 on Problem 2140
In Reply To:怎么才能不超时???我已经很费力了!!! Posted by:90405129 at 2004-12-21 19:48:28
> #include<stdio.h>
> #include<math.h>
> int i,j,n,t=0,s;
> void main(){
> 	scanf("%d",&n);
> 	for(i=1;s=i,i<=ceil(n/2);i++){
> 		for(j=i+1;j<=n;j++){
> 			s=s+j;
> 			if(s==n) {t++;break;}
> 			else if(s>n)break;
> 		}
> 	}
> 	printf("%d\n",t+1);
> }
>         


超时???我是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