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 |
一点想法,部分核心代码7 % 10 = 27 %10 = 3^3 %10 9 %10 = 3^2 %10 求出 末位为2,3,5,7,9各整数的个数, 而末位7,9转化为3 设 d2,d3,d5,d7,d9 为n!的因子末位为2,3,5,7,9的个数 d2 = d2 - d5; d3 = d3 + 2*d5 + 3*d7 偶的算法核心如下,没有给出 Get3(int n); n,m比较接近有很大因该单独处理不用递归 void fact5(int64 n) { if(n>1) { d5 += (n+5)/10; Get3(n/5); fact5(n/5); } } void fact2(int64 n) { if(n>1) { printf("n = %d ,d2 = %I64d,\n",n, d2); d2 += n/2; Get3(n); fact5(n); fact2(n/2); } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator