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 |
贴个公式在上面设起始数为i,连续数的个数为j,则最后一个数为j+i-1;推得(2*i+j-1)*j=2*n,n就是那个要分的数;因为2*i-1>0;所以(2*i+j-1)*j=2*n>j*j,所以j<sqrt(2*n),对于j满足2*n%j=0&&(2*n/j-j+1)%2=0.一个j对应一个i,j就是要求的数目。是个o(n)的算法,不知道有没有更快的 Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator