
数论
文章平均质量分 88
zhengnanlee
这个作者很懒,什么都没留下…
展开
-
poj2891
难得见中级中的水题。。 一开始做,想着存下来,如下: #include using namespace std; #define LL long long #define MAXN 100000000 LL ext_gcd(LL a, LL b, LL& x, LL& y) { LL t, ret; if (!b) {原创 2013-10-08 10:18:43 · 1900 阅读 · 0 评论 -
poj1845(有错)
数论知识知,一个数的因子和函数sigma(n)有如下定义: 其中 而又知 所以原创 2013-08-11 00:11:32 · 1731 阅读 · 1 评论 -
poj2115
构造出模线性方程c * x = b - a mod (2 ^ k) 很容易解。 利用LRJ书上的方法。 #include using namespace std; #define LL long long int LL ext_gcd(LL a, LL b, LL& x, LL& y) { LL t, ret; if (!b){ x = 1, y = 0; return原创 2013-08-09 16:41:14 · 1446 阅读 · 1 评论 -
poj1006
数论跪了三天。。 这个题不难得到(n+d)%23=p; (n+d)%28=e; (n+d)%33=i 如何求解? 首先介绍一个所谓“逆”的概念。 给定整数a,有(a,m)=1,称ax=1(mod m)的一个解叫做a模m的逆。 下面给出求逆的程序。 #include #include using namespace std; typedef long long LL;原创 2013-08-09 11:01:57 · 2013 阅读 · 1 评论 -
poj1061
构造方程 (x + m * s) - (y + n * s) = k * l(k = 0, 1, 2,...) 变形为 (n-m) * s + k * l = x - y。即转化为模板题,a * x + b * y = n,是否存在整数解。 #include using namespace std; #define LL long long LL g原创 2013-09-12 16:24:38 · 2500 阅读 · 0 评论 -
poj2635
这个题主要是要学会高精度求模。 思路有二,首先转化成千进制,然后利用“同余模定理”,或称“同余定理”。 比较实用的几条规律: 例如,想求123%4,可以这么操作 (100%4+20%4+3%4)%4。利用了性质1、性质3。 为何把它化作千进制,因为利用性质三,可知其是正确的。化作千进制,求模就变成了不超过1000的数的模,虽然次数增多,但是可以求解大数的模。 #include原创 2013-08-09 14:41:13 · 1300 阅读 · 0 评论 -
poj3101
不难,结果: 程序: import java.math.*; import java.util.*; public class Main { public static void main(String[] args) { Scanner cin = new Scanner(System.in); while(cin.hasNext())原创 2013-10-10 16:02:03 · 1651 阅读 · 0 评论 -
Recent Contest #1(Mar 18-Mar24, 2014)
http://acm.hust.edu.cn/vjudge/contest/view.action?cid=42423#overview A水题不述 B题是重点 公式不难想: 直接算肯定坑爹,有三种优化方法: 1、巧妙地乘法: double calc(int n, double p) { double ans = n * p; double temp =原创 2014-03-25 21:11:27 · 1402 阅读 · 0 评论