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 |
一个比较挫的办法~~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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator