题目链接:http://poj.org/problem?id=3239 构造法很牛逼啊,把这个搜索的题直接变成了打表. 我用dfs写了一下. 构造法公式(序列):一.当n mod 6 != 2 或 n mod 6 != 3时: [2,4,6,8,...,n],[1,3,5,7,...,n-1] (n为偶数) [2,4,6,8,...,n-1],[1,3,5,7,...,n ] (n为奇数)二.当n mod 6 == 2 或 n mod 6 == 3时 (当n为偶数,k=…
1.Link: http://poj.org/problem?id=3239 2.Content: Solution to the n Queens Puzzle Time Limit: 1000MS Memory Limit: 131072K Total Submissions: 3459 Accepted: 1273 Special Judge Description The eight queens puzzle is the problem of putting eight…
BSGS算法,预处理出ϕ(c)−−−−√内的a的幂,每次再一块一块的往上找,转移时将b乘上逆元,哈希表里O(1)查询即可 #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #include<cmath> #include<map> #define LL long long long long a,b,c,m; bool bo=0; std…
转自——http://blog.csdn.net/qwe20060514/article/details/8112550 =============================以下是最小生成树+并查集======================================[HDU]1213 How Many Tables 基础并查集★1272 小希的迷宫 基础并查集★1325&&poj1308 Is It A Tree? 基础并查集★1856 More i…