摘要:
转自: http://hi.baidu.com/pty123/item/06730a080b8523354bc4a356逆元的几种求法定义 a * x = 1(mod p),求x1、扩展欧几里德:令ax + py = 1Gcd的本质就是进行迭代,不断缩小范围。不详细讲。。参考:http://baike.baidu.com/view/1478219.htm2、根据费马小定理:若(a,p)互质,且p为质数:则 a ^ (p – 1)= 1 (% p)所以x = a ^ (p- 2) (% p)快速幂求之,查询log(n),常数比扩展欧几里德稍大3、O(n)预处理-O(1)询问预处理1-n关于p的逆 阅读全文
摘要:
DiceTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 126 Accepted Submission(s): 75Problem DescriptionGiven a normal dice (with 1, 2, 3, 4, 5, 6 on each face), we define: F(N) to be the expected number of tosses until we have a number facing ... 阅读全文
摘要:
Aeroplane chessTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 915 Accepted Submission(s): 631Problem DescriptionHzz loves aeroplane chess very much. The chess map contains N+1 grids labeled from 0 to N. Hzz starts at grid 0. For each step h... 阅读全文
摘要:
HintFor the fourth test case, (A,B) can be (0,5), (0,-5), (5,0), (-5,0), (3,4), (3,-4), (-3,4), (-3,-4), (4,3) , (4,-3), (-4,3), (-4,-3) Source 2011 Multi-University Training Contest 1 - Host by HNU Recommendxubiao 1 //31MS 280K 439 B C++ 2 //简单题..O(lgn) 3 #include 4 #include 5 int Pow(i... 阅读全文
摘要:
StringTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 1162 Accepted Submission(s): 426Problem DescriptionGiven 3 strings A, B, C, find the longest string D which satisfy the following rules:a) D is the subsequence of Ab) D is the subsequence... 阅读全文