随笔分类 -  数论

OJ上数论相关题,数论学习笔记
摘要:题目:http://poj.org/problem?id=1183思路:知道要推导公式,根据公式(4)的两种形式推来推去,似乎没有太大结果。看了Discuss里大牛的推导,看懂之后就很简单了,关键就是b = a+m, c = a+n .借用大牛的推导……1/a = (1/b + 1/c)/ (1 - 1/(b*c)) => bc-1 = a(b+c) assume b=a+m and c=a+n (b and c is always bigger than a) (a+m)(a+n)-1=a(a+m+a+n) => a*a+a*n+a*m+m*n-1=2*a*a+m*a+n*a = 阅读全文
posted @ 2011-07-24 17:14 cloehui 阅读(321) 评论(0) 推荐(0)
摘要:题目:http://acm.hdu.edu.cn/showproblem.php?pid=3400题目大意:给出A、B、C、D四点坐标,在AB上速度为P,CD上速度为Q, 其他地方速度为R。求从A到D的最短时间思路:两个三分嵌套,AB线段三分,内层嵌套CD线段内的三分提交情况: WA 1次, AC 1次总结:内层的三分时,每次都要重新赋两端点的值为C、D的值,因为前一次搜索结束后,端点值已经改变。就这样WA了一次……AC code:View Code 1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <st 阅读全文
posted @ 2011-07-24 10:34 cloehui 阅读(365) 评论(0) 推荐(0)