上一页 1 ··· 9 10 11 12 13 14 15 16 17 ··· 56 下一页
摘要: 将递归改成非递归,将递归入口改成对应的if...else...条件语句,在其中执行相同的操作 #include <iostream> #include <stack> using namespace std; int n, m; struct State { int pos, u, sum, sta 阅读全文
posted @ 2019-11-06 20:35 青衫客36 阅读(120) 评论(0) 推荐(0) 编辑
摘要: 感谢lyn大佬的指导,感谢CSDN博主「昂昂累世士」的博客 刚开始一直是以城区一的中心为原点,然后图一的四个点坐标分别为:(-1,1),(1,1),(1,-1),(-1,-1)左上角:(x,y)关于原点顺时针90度旋转得到(y,-x)再关于y轴轴对称变换得到(-y,-x);右上角:(x,y)向右平移 阅读全文
posted @ 2019-11-06 19:34 青衫客36 阅读(140) 评论(0) 推荐(0) 编辑
摘要: /* A = p1^k1 * p2^k2 * ... * pn^kn 所有的约数的个数: (k1 + 1) * (k2 + 1) * ... * (kn + 1) 所有的约数之和: (p1^0 + p1^1 + ... + p1^k1) * (p2^0 + p2^1 + ... + p2^k2) * ... * (pn^0 + pn^1 + ... + pn^kn) */ /* sum(p, k) 阅读全文
posted @ 2019-11-02 10:23 青衫客36 阅读(183) 评论(0) 推荐(0) 编辑
摘要: d[i]表示在三根木棍的情况下,i个盘子要走d[i]步(注意,d[i] 当前i个盘子,三根木棍均可走) f[i]表示在四根木棍的情况下,i个盘子要走的最短步数f[i]步(注意,f[i] 当前i个盘子,四根木棍均可走) f[j] * 2 或 d[i - 1] * 2 表示拿下j(或i - 1)个盘子放 阅读全文
posted @ 2019-11-01 19:33 青衫客36 阅读(160) 评论(0) 推荐(0) 编辑
摘要: #include <iostream> #include <cstring> using namespace std; const int INF = 0x3f3f3f3f; char g[10][10]; int dx[5] = {0, -1, 0, 1, 0}, dy[5] = {0, 0, 1, 0, -1}; void turn(int x, int y) { for(int i = 0; 阅读全文
posted @ 2019-11-01 19:24 青衫客36 阅读(129) 评论(0) 推荐(0) 编辑
摘要: #include <iostream> #include <vector> using namespace std; int n; vector<int> path; void dfs(int u, int state) { if(u == n) { for(auto x : path) cout << x << " "; cout << endl; return ; } for(int i = 阅读全文
posted @ 2019-10-27 21:14 青衫客36 阅读(146) 评论(0) 推荐(0) 编辑
摘要: #include <iostream> using namespace std; int n, m; void dfs(int u, int sum, int state) { // 判断边界条件 // 如果加上剩余的数都不够m个,直接return if(sum + n - u < m) return ; // 当达到m个数的时候 if(sum == m) { for(int i = 0; i < 阅读全文
posted @ 2019-10-27 20:47 青衫客36 阅读(136) 评论(0) 推荐(0) 编辑
摘要: #include <iostream> #include <cstring> #include <algorithm> using namespace std; /* 1. 哪些点被用过 2. 目前停在哪个点上 2^20 * 20 => 2*10^7 f[state][j]: state表示当前哪个点被用过, j表示最后停在哪个点上 f[state][j] = f[state_k][k] + we 阅读全文
posted @ 2019-10-24 18:45 青衫客36 阅读(106) 评论(0) 推荐(0) 编辑
摘要: #include <iostream> using namespace std; int main() { long long a, b, p; cin >> a >> b >> p; long long res = 0; while(b) { if(b & 1) res = (res + a) % p; a = (a + a) % p; b >>= 1; } cout << res << end 阅读全文
posted @ 2019-10-20 19:15 青衫客36 阅读(191) 评论(0) 推荐(0) 编辑
摘要: #include using namespace std; int main() { long long a, b, p; cin >> a >> b >> p; long long res = 1 % p; //此处若不mod p,则测试用例为 123456789 0 1 时,会输出1,但应该输出0 while(b) { if(b & 1) res = res *... 阅读全文
posted @ 2019-10-20 18:25 青衫客36 阅读(123) 评论(0) 推荐(0) 编辑
上一页 1 ··· 9 10 11 12 13 14 15 16 17 ··· 56 下一页