题目地址:http://www.patest.cn/contests/pat-a-practise/1001我乱搞的, 复习stringstream 1 #include 2 #include 3 #include 4 5 using namespace std; 6 7 const int S... Read More
posted @ 2015-04-10 02:02 ACSeed Views(156) Comments(0) Diggs(0)
题目地址:http://www.patest.cn/contests/pat-a-practise/1098本来试图复习一下c++的继承, 无奈都忘光了, static 成员, 抽象类, 纯虛函数。。。。c++语法都忘光了, 一个语句: A a = new A(); 竟然编译不过, 必须用指针接, ... Read More
posted @ 2015-04-10 01:12 ACSeed Views(328) Comments(0) Diggs(0)
地址:http://www.patest.cn/contests/pat-a-practise/1097没什么好说的, 我逗比就是了 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 8 usin... Read More
posted @ 2015-04-09 22:08 ACSeed Views(245) Comments(0) Diggs(0)
地址:http://www.patest.cn/contests/pat-a-practise/1096这是在pat做的第一个题目, 由于脑残交了十几次才过。刚看到这个题目第一印象就是一个数的因子数不会太多, 我全找出来就好了, 然后就开始乱搞了, 打素数,分解, 然后找出所有的因子开始我认为 2^... Read More
posted @ 2015-04-08 23:57 ACSeed Views(1248) Comments(0) Diggs(2)
1)威尔逊定理: 当且仅当p为素数时2)中国剩余定理: http://www.cnblogs.com/ACSeed/archive/2013/01/31/2887288.html3)欧拉定理 : 若n,a为正整数,且n,a互质,gcd(a,n)=1,则4)费马小定理 :假如a是一个整数,p是一个质数,那么如果a不是p的倍数,这个定理也可以写成更详细的见这里:http://xueke.maboshi.net/sx/sxgj/sxsh/shsl/81433.html Read More
posted @ 2013-01-31 16:43 ACSeed Views(1520) Comments(0) Diggs(0)
假设有方程组x = ai(mod mi), 其中所有的mi两两互素, 另M为所有mi的乘积, wi = M / mi, 则gcd(wi, mi) = 1, 用扩展gcd可以得到wipi + miqi = 1的解, 然后ei = wipi, 则方程组等价于x = e1a1 + e2a2 + .... + enan (mod M), 即在模M下方程组有唯一解。View Code 1 ll china(ll n, ll *a, ll *m) 2 { 3 ll M = 1, d, y, x = 0; 4 for(int i = 0; i < n; ++i) M *= m[i]... Read More
posted @ 2013-01-31 16:29 ACSeed Views(354) Comments(0) Diggs(0)
1)求解线性不定方程 ax + by = c 先求出一组解, 然后考虑如何表示通解, 设d = gcd(a, b), 假设c不是d的倍数, 则左边是d的倍数而右边不是, 则方程无解, 所以方程有解当且仅当d | c. 设c = c' * d, 我们先考虑方程 ax + by = d, 这样由扩展gcd便可求出一组解 (x', y'), 则(c'x', c'y')就是原方程的一组解,然后考虑通解: 假设有两组解(x1, y2) , (x2, y2), 有 ax1 + by1 == ax2 + by2 = c, 移项得: a(x1 - x2) Read More
posted @ 2013-01-31 16:09 ACSeed Views(4725) Comments(0) Diggs(1)
1)有限群 群(S, *)是一个集合和定义在集合上的二进制运算*(注: 这里的*区别于乘号), 它满足性质:封闭性, 有单位元, 满足结合律, 每个元素存在逆元; 如果还满足交换律, 则称他为交换群或Abel群; 如果S集合是有限的, 则称它为有限群;2)根据模加法和模乘法所定义的群 (1)加法的定义同普通的整数加法,只是在模n的意义下进行。如3 和 4 在模5下为 3 + 4 = 2, 通常用(Zn, +n)表示; 可以证明(Zn, +n)是一个有限可交换群。 (2)乘法不能像普通乘法那样定义了, 因为不是每个元素都存在逆元。定义群(Zn*, *n)的集合如下: Z... Read More
posted @ 2013-01-31 14:12 ACSeed Views(1998) Comments(0) Diggs(0)
1)GCD递归定理: gcd(a, b) = gcd(b, a % b); 证明通过证两边的式子互相整除。 直接应用上面定理的就是欧几里德算法:View Code 1 typedef long long ll;2 ll gcd(ll a, ll b) {3 return b ? gcd(b, a % b) : a;4 } 关于时间性能, 连续的斐波那契数是欧几里德算法的最坏情况下的一种输入,所以时间约为O(log(b));2)扩展GCD: 推广欧几里德算法能使它计算满足下列条件的整系数x, y: d = gcd(a, b) = ax + byView Code 1 type... Read More
posted @ 2013-01-31 13:02 ACSeed Views(220) Comments(0) Diggs(0)