| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
用函数就一切OK!!!In Reply To:怎么才能不超时???我已经很费力了!!! Posted by:90405129 at 2004-12-21 19:48:28 #include<stdio.h>
int f(int n){
int s=0,i,j,sum;
for(i=1;i<=n;i++){
sum=0;
for(j=i;j<=n;j++){
sum+=j;
if(sum==n){s++;break;}
if(sum>n)break;
}
}
return (s);
}
void main(){
int n;
scanf("%d",&n);
printf("%d\n",f(n));
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator