摘要:
SudokuTime Limit: 1000MSMemory Limit: 65536KTotal Submissions: 8909Accepted: 3196DescriptionIn the game of Sudoku, you are given a large 9 × 9 grid di... 阅读全文
随笔分类 - Algorithm
sudoku,数独,poj2676
2015-08-26 11:22 by iun, 172 阅读, 收藏,
摘要:
每次从状态数最小的位置开始搜索#include #include using namespace std;int g[9][9];int row[9][10];int col[9][10];int cell[9][10];int getId(int x,int y){ return (x/3)... 阅读全文
子集枚举
2015-08-25 22:27 by iun, 238 阅读, 收藏,
摘要:
#include #include #include using namespace std;//枚举包含n个元素的集合中大小是k的子集void subset_n_k(int n,int k){ int sub = 1; int end_state; for(int i= 1;i>... 阅读全文
组合数生成算法
2015-08-25 22:02 by iun, 541 阅读, 收藏,
摘要:
#include #include #include using namespace std;bool next_combination(vector& vec,int n){ int k = vec.size() - 1; for(;k>=0;k--){ if(vec[k... 阅读全文
全排列生成算法
2015-08-25 21:25 by iun, 294 阅读, 收藏,
摘要:
全排列的生成算法, next_permutation_1可以用于生成多重集的全排列,next_permutation_2不能用于多重集#include #include #include using namespace std;bool next_permutation_1(vector& vec)... 阅读全文
第k个排列数
2015-08-25 20:47 by iun, 340 阅读, 收藏,
摘要:
变长编码,这里排列的序号是0到n!-1,假设求 1,2,3,4的第15个排列数,15/(3!) = 2,余数是3,第一个数是(1,2,3,4)中的第二个数 3 (这里0是开始位置),3/(2!) = 1,余数是1,第二个数就是(1,2,4)中的第一个数 2, 1/(1!) = 1,余数是0,第三个数... 阅读全文
Google 2015 apac test Problem A, Seven-segment Display
2015-08-16 20:29 by iun, 418 阅读, 收藏,
摘要:
Problem A. Seven-segment Display This contest is open for practice. You can try every problem as many times as you like, though we won't keep track of... 阅读全文
Prime counting,sum of primes,leetcode,dp.
2015-07-16 17:13 by iun, 281 阅读, 收藏,
摘要:
主要参考 http://www.zhihu.com/question/29580448/answer/45218281https://projecteuler.net/thread=10;page=5 Lucy_Hedgehog的代码如果不用map,自己写hash函数会更快// 计算 Π(n-1)c... 阅读全文
浙公网安备 33010602011771号