- 博客(6)
- 资源 (5)
- 收藏
- 关注
原创 POJ 1111 Image Perimeters
1. 写得最有逻辑的一道题了,10次讲座学的最好的就是DFS和BFS了。 2. 直接深搜 #include #include #include #include #include #include #include #include #include #include using namespace std; int a, b, sx, sy; char map[25][
2012-07-10 16:25:53 451
原创 POJ 1125 Stockbroker Grapevine
#include #include #include #include #include #include #include //#include #include #include const int INT_MAX = (1 << 21); using namespace std; int d[105][105]; struct Node { int x, y, d
2012-07-10 15:27:15 367
转载 【转】素数相关算法总结
定义:除了1和其本身,没有其他约数的数。 测试:用n分别试除2到sqrt(n)的数,如果中间有一个能整除,即 为合数,否则即为素数 bool is_prime(int n)//判断n是否为素数,是素数返回1 { int i; bool flag = 1; for(i = 2; i <= sqrt(n); i++) { if(n % i
2012-07-08 21:54:50 363
原创 POJ2247 Humble Numbers
#include #include #include #include #include #include #include using namespace std; int num[5845]; void f() { int i, j, k, l, temp; i = j = k = l = 2; memset(num, 0, sizeof(num));
2012-07-08 14:00:07 414
原创 POJ 1915
1. 简单的bfs,有用双向bfs的,但是为了赶进度,以后用双向bfs实现 #include #include #include #include #include #include #include using namespace std; int dir[8][2] = {{-2, 1}, {-1, 2}, {1, 2}, {2, 1}, {2, -1}, {1, -2},
2012-07-07 15:13:14 477
原创 POJ1308 Is It A Tree?
1. 并查集,有点忘了,看维基百科回顾起来了,三个操作,路径压缩、合并、查找父节点。代码很简单,具体参考http://zh.wikipedia.org/wiki/%E5%B9%B6%E6%9F%A5%E9%9B%86 2. WA了好多次,最后发现是当空树的时候也是一棵树,fuck。。。 #include #include #include #include #include #inc
2012-07-07 09:53:04 411
列车运行两阶段仿真研究
2011-09-29
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人