摘要: 听说3^n也能水过去。。 其实应该是个经典题,求图染色这个np问题。 把问题拆成独立集来进行dp可以在3^n之内水过去。 拆成独立集的时候就发现,等价与一个经典的反演dp问题 然后复杂度就变成了 n*n*2^n 另外,偷到一套头文件宏定义。 阅读全文
posted @ 2016-08-23 21:40 chenhuan001 阅读(312) 评论(0) 推荐(0) 编辑
摘要: 咋一看,至少要用3^n才能做到。 但。 首先定义: 可以发现只要求出a' b' 那么直接可以得出c' 那么如何求a'呢 有了a'之后,观察式子发现直接逆着写,就可以从a'->a 然后反演即为: 然后就可以在n*2^n 内求出C 参考:炫酷反演魔术 阅读全文
posted @ 2016-08-23 21:32 chenhuan001 阅读(459) 评论(0) 推荐(0) 编辑
摘要: #pragma comment(linker, "/STACK:102400000,102400000") #include #include #include #include #include #include #include #include #include #include #include #include #include #include #defi... 阅读全文
posted @ 2016-08-23 15:25 chenhuan001 阅读(189) 评论(0) 推荐(0) 编辑
摘要: //测时间 class Timer { private: clock_t _start; clock_t _end; public: Timer() { start(); } void start() { _start = clock(); } double get() { _end = clock(); ... 阅读全文
posted @ 2016-08-23 14:41 chenhuan001 阅读(222) 评论(0) 推荐(0) 编辑
摘要: /* 幻方的计算: 计算任意阶数幻方的各行、各列、各条对角线上所有数的和的公式为:sum=n*(n^2+1)/2 n为阶数 幻方分为奇阶幻方和偶阶幻方 一、当n为奇数时称为奇阶幻方 1、Merzirac法生成奇阶幻方 在第一行居中的方格内放1,依次向右上方填入2、3、4…,如果右上方已有数字,则向下移一格继续填写。 ... 阅读全文
posted @ 2016-08-23 11:17 chenhuan001 阅读(639) 评论(0) 推荐(0) 编辑