
dfs
文章平均质量分 71
guojiaqi007
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
九度 oj 题目1038:Sum of Factorials
http://ac.jobdu.com/problem.php?pid=1038 这道题首先想到用组合数,如果要列出完整的组合内容应考虑到用所有组合, 所有排列的模板。如果只是要组合的和(或者积)就相当于二叉搜索,中途还可以剪枝。 code1: #include static int f[11]; static int n; void make_f(){ f[0] =原创 2017-02-07 10:40:04 · 405 阅读 · 0 评论 -
九度 oj 题目1091:棋盘游戏
http://ac.jobdu.com/problem.php?pid=1091 #include #include static const int d[4][2] = {{0,-1},{0,1},{-1,0},{1,0}}; static int value[6][6]; static bool mark[6][6]; static int mincost,sx,sy,ex,ey原创 2017-02-07 22:22:23 · 351 阅读 · 0 评论 -
pat 1103. Integer Factorization (30)
https://www.patest.cn/contests/pat-a-practise/1103 参考了: http://blog.youkuaiyun.com/apie_czx/article/details/48415197 此题不是素数的分解,所以用了搜索,因为k不大,n也不大。 直接用pow(i,p) 会超时 从小到大遍历,如果出现sum相同的(there i转载 2017-02-17 14:55:22 · 180 阅读 · 0 评论 -
九度 oj 题目1140:八皇后
http://ac.jobdu.com/problem.php?pid=1140 #include #include static int map[8][8]; static int pos[8]; static int ans[92],cn; void deploy(int i, int j, int v){ int _i=i,_j=j; while(_i<8) m原创 2017-01-25 16:43:30 · 407 阅读 · 0 评论 -
pat-top 1006. Tree Traversals - Hard Version (35)
https://www.patest.cn/contests/pat-t-practise/1006 code 来自于http://blog.youkuaiyun.com/jtjy568805874/article/details/50759512 dfs 在中序遍历序列中穷举 root 的位置,因为root可能会被替换,所以使用数组存储树。 #include #include #i转载 2017-03-01 21:39:08 · 2433 阅读 · 1 评论 -
pat-top 1004. To Buy or Not to Buy - Hard Version (35)
https://www.patest.cn/contests/pat-t-practise/1004 dfs+剪枝,但是依然有2个case TLE,最后像http://blog.youkuaiyun.com/jtjy568805874/article/details/50759483 使用了寻找近似解的方法。 #include #include #include #include #inc原创 2017-02-22 19:24:55 · 498 阅读 · 0 评论 -
pat-top 1012. Greedy Snake (35)
https://www.patest.cn/contests/pat-t-practise/1012 参考了http://blog.youkuaiyun.com/jtjy568805874/article/details/52517821 #include #include #include #include using namespace std; const int ma转载 2017-03-03 17:27:17 · 582 阅读 · 0 评论