摘要: dp[i][j]=1表示用前i个数字可以凑成余数为j。若dp[i-1][j]=1 ,则dp[i][(j+num[i])%k]=1;dp[i][((j-num[i]+k)%k+k)%k]=1#include #include #include #include using namespace std;... 阅读全文
posted @ 2015-04-08 16:12 Scale_the_heights 阅读(216) 评论(0) 推荐(0)
摘要: [困]坑点:无向边,每条边只能走一次,但正向走一次后反向还能走一次,所以每次输入要建四条边。#include #include #include #include #include using namespace std;int n,m,cnt;int head[50500],vis[50500],... 阅读全文
posted @ 2015-04-02 22:32 Scale_the_heights 阅读(352) 评论(0) 推荐(0)
摘要: 推荐一个学习网络流入门的资料 http://acm.pku.edu.cn/summerschool/gw_netflow.pdf本题为网络流水题,也是pdf中将网络流的一道题,注意重边即可。#include #include #include #include #include using name... 阅读全文
posted @ 2015-03-28 21:42 Scale_the_heights 阅读(161) 评论(0) 推荐(0)
摘要: 欧拉函数:x以内与x互质的数的个数φ(x)=x(1-1/p1)(1-1/p2)(1-1/p3)(1-1/p4)…..(1-1/pn) 阅读全文
posted @ 2015-03-27 13:25 Scale_the_heights 阅读(428) 评论(0) 推荐(0)
摘要: 定理1 令(X,≤)是一个有限偏序集,并令r是其最大链的大小。则X可以被划分成r个但不能再少的反链。其对偶定理称为Dilworth定理:定理2 令(X,≤)是一个有限偏序集,并令m是反链的最大的大小。则X可以被划分成m个但不能再少的链。也就是说:最小划分数=反链的最大长度 阅读全文
posted @ 2015-03-25 09:31 Scale_the_heights 阅读(300) 评论(0) 推荐(0)
摘要: 挑战程序设计上有解答的并查集好题。把事件作为元素进行合并,举例:若输入1 2 3,意思就是把2,3归为同一类,至于归于哪一类并不需要去讨论,则把2属于A,3属于A这两件事件归为一类;2属于B,3属于B这两件事归为一类;2属于C,3属于C这两件事归为一类;若输入 2 2 3,由于A吃B,B吃C,C吃A... 阅读全文
posted @ 2015-03-21 22:57 Scale_the_heights 阅读(154) 评论(0) 推荐(0)
摘要: 方法(无证明,lz弱渣请谅解):以样例来讲:(x^6 + x^4 + x^2 + x + 1) (x^7 + x + 1) modulo (x^8 + x^4 + x^3 + x + 1) = x^7 + x^6 + 1 。(x^6 + x^4 + x^2 + x + 1) (x^7 + x + 1... 阅读全文
posted @ 2015-03-19 21:48 Scale_the_heights 阅读(198) 评论(0) 推荐(0)
摘要: 题目链接输入n个数(0或1),问是否能通过若干次交换相间的两个数字使得所有1都相邻。解法:当n为奇数时任意两个数字都能交换,当然是yes。当n为偶数时相间的两数字可以互相交换,这样会出现两组排列,然后把排列a插入排列b。并且b的相邻两个元素间只能插一个a的元素。要使所有的1相邻,显然a,b中1的个数... 阅读全文
posted @ 2015-03-15 22:06 Scale_the_heights 阅读(172) 评论(0) 推荐(0)
摘要: 题目链接求让城市1到其他城市在保证最短路的情况下求最小花费,最短路水题。#include #include #include #include using namespace std;const int INF=1e9;struct edge{ int u,v; int len,cost... 阅读全文
posted @ 2015-03-15 00:39 Scale_the_heights 阅读(176) 评论(0) 推荐(0)
摘要: 题目链接输入一部字典,再输入要查询的单词。如果字典能查到就输出。不能的话就输出eh。代码#include #include #include #include #include using namespace std;int main(){ map mmap; string str; ... 阅读全文
posted @ 2015-03-13 14:25 Scale_the_heights 阅读(142) 评论(0) 推荐(0)