摘要: 百度文库搜trie图利用安全图的概念可以做POJ2778POJ2778 1 #include <cstdio> 2 #include <cstring> 3 const int p = 1e5; 4 int trie[170][4], map[255], fail[150], q[2000000], cnt; 5 bool v[170]; 6 struct M { 7 long long s[170][170]; 8 M () { memset (s, 0, sizeof s); } 9 }x, ans;10 inline M operator * (const M & 阅读全文
posted @ 2013-02-08 16:58 Moretimes 阅读(188) 评论(0) 推荐(0) 编辑
摘要: x * x + y * y = r * r的(正整数解 + 1) 2 #include 3 long long r; 4 inline long long gcd (long long a, long long b) { return b == 0 ? a : gcd (b, a % b); }... 阅读全文
posted @ 2013-02-08 16:54 Moretimes 阅读(1131) 评论(0) 推荐(0) 编辑
摘要: A1 + X1 - X2 = GA2 + X2 - X3 = G...An + Xn - X1 = G解得X1 = X1X2 = A1 - G + X1X3 = A1 + A2 - G - G + X1...Xn = sigma(1, n)A - n * G + X1注意到ans = abs (X1 - lamda1) + abs (X2 - lamda2) + ... + abs (Xn - lamdan)于是sort 取中位数代码丑极了替换的 1 #include <cstdio> 2 #include <cstdlib> 3 #include <algori 阅读全文
posted @ 2013-02-08 16:47 Moretimes 阅读(519) 评论(0) 推荐(0) 编辑