摘要: 题目描述:如标题思路:一比一比根号二咯 1 #include 2 #include 3 #include 4 using namespace std; 5 6 const int N = 4; 7 8 struct Node 9 {10 int x, y, z;11 } node... 阅读全文
posted @ 2015-04-19 00:16 hxy_has_been_used 阅读(346) 评论(0) 推荐(0) 编辑
摘要: 题目大意:求最大的两个数的最大公约数。思路:数据范围较小,只有10^5,可以考虑哈希。解法1: 1 #include 2 #include 3 #include 4 using namespace std; 5 6 const int N = 100001; 7 int hash_table... 阅读全文
posted @ 2015-04-18 23:46 hxy_has_been_used 阅读(224) 评论(0) 推荐(0) 编辑
摘要: 最小点覆盖集的裸题,只要“拆点建边”然后求出最大匹配,则:最小点覆盖集的大小 = 点数 - 最大匹配 1 #include 2 #include 3 #include 4 using namespace std; 5 6 const int N = 121; 7 const int M = ... 阅读全文
posted @ 2015-04-17 23:57 hxy_has_been_used 阅读(146) 评论(0) 推荐(0) 编辑
摘要: 很显然是快速幂,数据太小了,int就足够。 1 #include 2 using namespace std; 3 4 int pow_mod( int a, int n, int m ) 5 { 6 int ans = 1; 7 a = a % m; 8 while (... 阅读全文
posted @ 2015-04-17 20:09 hxy_has_been_used 阅读(119) 评论(0) 推荐(0) 编辑
摘要: 题目大意:组合数取模,n和m并不算大,p比较大且是合数。思路:暴力分解+快速幂注:暴力也是有区别的,分解质因数时可以用以下work函数,写的非常巧妙,摘录自互联网。 1 #include 2 #include 3 using namespace std; 4 5 typedef long lo... 阅读全文
posted @ 2015-04-16 23:23 hxy_has_been_used 阅读(186) 评论(0) 推荐(0) 编辑
摘要: 一开始想多了,以为应该做个数位dp的,后来想了想也不过100W的数据,直接暴力好像也不慢,于是暴力就过了,还挺快。 1 #include 2 using namespace std; 3 4 bool judge( int x, int d ) 5 { 6 while ( x ) 7 ... 阅读全文
posted @ 2015-04-16 21:53 hxy_has_been_used 阅读(137) 评论(0) 推荐(0) 编辑
摘要: tarjan求强连通分量的裸题复习,可当做模板。 1 #include 2 #include 3 #include 4 using namespace std; 5 6 const int N = 10001; 7 const int M = 100000; 8 int dfn[N], lo... 阅读全文
posted @ 2015-04-15 21:55 hxy_has_been_used 阅读(128) 评论(0) 推荐(0) 编辑
摘要: 题目大意:判断组合数C(n,k),k<=n的奇偶性。 解法:C(n,k)的奇偶性取决于(n-k)和k对应的二进制数上是否有至少一位同为1,若有则为偶数,反之为奇数。 阅读全文
posted @ 2015-04-14 18:18 hxy_has_been_used 阅读(304) 评论(0) 推荐(0) 编辑
摘要: 插板法求得答案为:C(n+m,m)。直接运用lucas定理即可,只是需要预处理出阶乘值,否则会T。 1 #include 2 3 typedef long long ll; 4 const int N = 100000; 5 int f[N]; 6 7 void init( int p ) 8... 阅读全文
posted @ 2015-04-14 17:48 hxy_has_been_used 阅读(142) 评论(0) 推荐(0) 编辑
摘要: 由于p是素数,计算逆元可以借助费马小定理,用扩展欧几里得也可以,不过预计比快速幂慢吧。 代码如下: 参考于:http://m.blog.csdn.net/blog/acdreamers_11109/8037918 阅读全文
posted @ 2015-04-14 17:11 hxy_has_been_used 阅读(285) 评论(0) 推荐(0) 编辑