pku acm 2140 Herd Sums http://acm.pku.edu.cn/JudgeOnline/problem?id=2140

2140代码短小精悍:

#include<stdio.h>
int main()
{
int cnt=0,i; 
long s;
scanf("%ld",&s);
for(i=1;(i+1)*i/2<=s;i++)
     if((s-(i-1)*i/2)%i==0)
   cnt++;
printf("%d\n",cnt);    
return 0;
}

posted on 2011-05-06 19:21  _Clarence  阅读(77)  评论(0编辑  收藏

导航