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 |
这个还能怎么优化阿,我优化了两处,但还是tle对每一个是2,或,5的倍数的都需要 while(!(t%2)) { t/=2; } while(!(t%5)) { t/=5; } 这个是最肥时间的 应该怎么优化 ,什么规律阿 对于不是2,5倍数 我用 1 *3 *7 *9 mod 10=9 9*9 mod 10 =1 优化 对于最后2的个数 我用 switch(num2%4) { case 0: result = (result*6) % 10;break; case 1: result = (result*2) % 10;break; case 2: result = (result*4) % 10;break; case 3: result = (result*8) % 10;break; } return result; Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator