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

一个比较挫的办法~~

Posted by conanhjj at 2009-02-23 22:41:59 on Problem 2140
for(i=1;i<=n;++i)
{
    t=(0+i-1)*i/2;
    t=n-t;
    if(t<=0) break;
    if(t%i==0) ++res;
}

统计长度,从1开始。。。
如果可以由k个数字构成 那么肯定可以表现成这种形式

思路:
a+0,a+1,a+2,....,a+(k-1)

因为 a+0+(a+1)..a+(k-1)=k*a + (k-1)*k/2 =n

所以 k*a=n-(k-1)*k/2
只要对应的k能确保a为整数,那么就可以确定满足条件的一组连续的k个数,所以++res

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