POJ刷题
hdsdogge
这个作者很懒,什么都没留下…
展开
-
POJ3126 Prime Path
要注意筛素数的时候要小于等于 第一次wa原因是有的是合数而判断为素数//总体思路 先打一张素数表 之后从千位开始改变状态 进行bfs #include<iostream> #include<queue> #define MAX 10001 using namespace std; bool prime[MAX]; //打一张素数表 int dis[MAX]; void原创 2017-11-28 20:30:39 · 119 阅读 · 0 评论 -
A Knight's Journey POJ - 2488
bfs+回溯注意方向 因为默认为A1第一个 如果要按照字典序输出方向导数不能错 记得回溯 即如果这条路不行就将走过的路恢复到原来的状态#include<iostream> #include<cstdio> using namespace std; int dx[] = { -1,1,-2,2,-2,2,-1,1 }; //方向不能错 因为要按照字典序输出 int dy[] = {原创 2017-10-27 16:11:48 · 145 阅读 · 0 评论 -
UVA - 1368 DNA Consensus String
思路:统计字符的最大值 若有相同的以字典序第一个为准输入 简单题#include<iostream> #include<cstdio> #include<string> #include<algorithm> using namespace std; int main() { int T, m, n; int i, j; int a_count = 0, g_count =原创 2017-10-08 10:09:30 · 170 阅读 · 0 评论 -
POJ - 3009 Curling 2.0
这是一个简单的BFS题目 当step>10时直接剪枝可以减少运算量 bfs结束进行回溯 用dfs有些复杂 因为棋盘是不断的在变化的#include<iostream> using namespace std; #define MAX_H 30 #define MAX_W 30 void input(int w, int h); void dfs(int sx, int sy, int d);原创 2017-11-26 13:54:12 · 187 阅读 · 0 评论 -
POJ 1321-棋盘问题
简单DFS 思路简单 别忘记把测试代码注释掉#include<iostream> using namespace std; char chess[10][10]; bool x_state[10]; bool y_state[10]; void input(); int valid(int x,int y); void dfs(int x, int y, int d); int n, num,原创 2017-11-26 22:32:25 · 152 阅读 · 0 评论 -
POJ3278 Catch That Cow
本来以为是一道很简单的题 然后后来RE了10次 看了看讨论区才知道是数组越界问题 就是一定要先判断数组有没有越界 附AC BFS写法#include<iostream> #include<queue> using namespace std; #define MAX 1000001 #define INF 1000000 void bfs(int n, int k); int d[MAX];原创 2017-11-27 20:53:18 · 145 阅读 · 0 评论 -
Cow Bowling POJ - 3176
很水的dp 拿来练手的 #include <iostream> const int maxn=360; int dp[maxn][maxn]; int arr[maxn][maxn]; int N; using namespace std; int main() { //freopen("in","r",stdin); //freopen("out","w",st...原创 2018-03-20 10:24:24 · 126 阅读 · 0 评论