摘要: 2维bit。每个颜色建一个。 #include #include #include using namespace std; const int maxn = 300+10; struct Bit2D { int a[maxn][maxn],n,m; inline int lowbit(int x) { return x&-x; } ... 阅读全文
posted @ 2016-04-25 22:56 invoid 阅读(167) 评论(0) 推荐(0) 编辑
摘要: 差分约束,dag最长路。 坑点在于有一个100000 长的链,虚拟节点倒序加就a了。 用queue是太懒,tyvj上过不了。 #include #include #include #include using namespace std; const int maxn = 100000 + 10; const int maxm = 400000 + 10; int n,k; i... 阅读全文
posted @ 2016-04-25 22:21 invoid 阅读(135) 评论(0) 推荐(0) 编辑
摘要: 一定要想到是最小割。 虚拟源点S连支持者容量为1,反对者连虚拟汇点容量为1,支持者连反对者容量为1。 割俩面的点,一面是支持,一面是反对,冲突数就是割(哥。。雾)。 最小冲突数就是最小割。 #include #include #include using namespace std; const int maxn = 300 + 10; const int maxm = 100000... 阅读全文
posted @ 2016-04-25 20:54 invoid 阅读(158) 评论(0) 推荐(0) 编辑
摘要: 欧拉函数。 首先设k为n的约数,则res+=(k*s(k))。s(k)为满足gcd(m,n)=k的m的个数。 因为gcd(m,n)=k,所以gcd(m/k,n/k)=1,则s(k) = phi(n/k)。 边界判断要注意。 每次加的为i和n/i。 如果i*i=n,要特判,否则会重复。 阅读全文
posted @ 2016-04-25 20:19 invoid 阅读(212) 评论(0) 推荐(0) 编辑