POJ
somniloquy_
为利益而活 如腐尸般不堪
展开
-
POJ-2376 Cleaning Shifts
贪心问题原创 2015-11-01 18:05:00 · 277 阅读 · 0 评论 -
POJ-3253 Fence Repair
优先队列 贪心 堆原创 2015-10-18 10:42:44 · 228 阅读 · 0 评论 -
POJ-1083 Moving Tables
模拟原创 2015-09-26 22:40:20 · 369 阅读 · 0 评论 -
POJ-3660 Cow Contest
#include <cstdio>#include <cstring>using namespace std;const int n_max = 100 + 5;const int m_max = 4500 + 5;int graph[n_max][n_max];int n, m;int a, b, cnt, ans;void Floyd(){ for(int k = 1; k <原创 2015-09-26 12:37:05 · 266 阅读 · 0 评论 -
POJ-3617 Best Cow Line
#include <cstdio>#include <cstring>#include <iostream>using namespace std;const int n_max = 2000 + 5;char cow[n_max];char dir[n_max];int n;int main(){ while(~scanf("%d", & n)) { f原创 2015-09-25 17:46:23 · 227 阅读 · 0 评论 -
POJ-3268 Silver Cow Party
#include <iostream>#include <cstdio>#include <algorithm>#include <cstring>#include <queue>using namespace std;const int maxn = 1005;const int INF = 1e8;int sign[maxn];int connect[maxn];int dis[原创 2015-09-08 21:13:08 · 222 阅读 · 0 评论 -
POJ-1426 Find The Multiple
#include #include #include #include #include #include #include #include typedef long long ll;using namespace std;const int INF = 0x3f3f3f3f;const double PI = 3.14159265;const double E =原创 2015-08-08 19:56:29 · 312 阅读 · 0 评论 -
POJ-1062 昂贵的聘礼
#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>#include <queue>#include <cmath>using namespace std;const int maxn = 105;struct node{ int from; int to; int原创 2015-09-09 18:18:02 · 262 阅读 · 0 评论 -
POJ-1321 棋盘问题
#include #include #include #include using namespace std;const int maxn = 9;char chess[maxn][maxn];int cross[maxn];int n, k, cnt, num;void dfs(int row){ if(k == num) { cnt原创 2015-08-06 17:25:25 · 234 阅读 · 0 评论 -
POJ-2431 Expedition
贪心 优先队列原创 2015-10-17 23:37:15 · 232 阅读 · 0 评论 -
POJ-1847 Tram
SPFA 最短路原创 2015-10-19 16:21:49 · 316 阅读 · 0 评论 -
POJ-3159 Candies
SPFA 差束约分原创 2015-10-19 17:22:55 · 308 阅读 · 0 评论 -
POJ-3061 Subsequence
二分搜索 子序列原创 2015-10-25 15:33:16 · 245 阅读 · 0 评论 -
POJ-3320 Jessica's Reading Problem
尺取法原创 2015-10-25 19:38:21 · 273 阅读 · 0 评论 -
POJ-1995 Raising Modulo Numbers
快速幂原创 2015-10-24 18:47:09 · 240 阅读 · 0 评论 -
POJ-3641 Pseudoprime numbers
快速幂原创 2015-10-24 18:27:02 · 259 阅读 · 0 评论 -
POJ-1601 青蛙的约会
扩展欧几里德定理原创 2015-10-22 19:24:35 · 498 阅读 · 0 评论 -
POJ-3255 Roadblocks
A* 求 第k短路 spfa原创 2015-10-21 18:48:30 · 256 阅读 · 0 评论 -
POJ-2449 Remmarguts' Date
A*算法求第k短路 单向边 SPFA原创 2015-10-22 12:04:30 · 267 阅读 · 0 评论 -
POJ-2718 Smallest Difference
爆搜原创 2015-11-04 16:18:16 · 243 阅读 · 0 评论 -
POJ-3278 Catch That Cow
#include #include #include #include using namespace std;const int maxn = 2e5;int sign[maxn];int n, k;struct Step{ int l; int step;} start;queue location;int bfs(){ if(start原创 2015-08-07 13:11:50 · 298 阅读 · 0 评论 -
POJ-3009 Curling 2.0
#include #include #include #include using namespace std;const int maxn = 25;int maze[maxn][maxn];int stp[4][2]={{0,-1},{0,1},{-1,0},{1,0}};int w, h, ans, flag;struct Maze{ int x; i原创 2015-08-06 15:14:30 · 248 阅读 · 0 评论 -
POJ-1852 Ants
#include #include #define maxn 1000000int cm[maxn],cm1[maxn],cm2[maxn];int time(int* cm,int k){ int x = 0; for(int i = 0;i < k; i++) { if(cm[i] > cm[x]) x = i;原创 2015-07-19 12:37:03 · 283 阅读 · 0 评论 -
POJ-2159 Ancient Cipher
#include #include #include void srt(int* k){ int i; for(i = 0;i < 26-1;i ++) { int index=i; for (int j=i+1;j < 26;j ++) { if(k[j原创 2015-07-18 11:34:45 · 248 阅读 · 0 评论 -
POJ-1606 Jugs
#include #include #include #include #include using namespace std;int CA, CB, n;char STEP[7][10] = {"success", "fill A", "fill B", "empty A", "empty B", "pour A B", "pour B A"};int sign[1001]原创 2015-08-09 17:00:19 · 350 阅读 · 0 评论 -
POJ-3126 Prime Path
#include #include #include #include using namespace std;int t, op, ed; //t为访问次数 op为第一个素数 ed为第二素数(即目标素数)int prime[10000]; //建立素数表int sign[10000]; //标记是否访问过int digit[4]; //分离每一原创 2015-08-09 13:10:12 · 348 阅读 · 0 评论 -
POJ-2488 A Knight's Journey
#include #include #include #include using namespace std;int dir[8][2]={{-1,-2},{1,-2},{-2,-1},{2,-1},{-2,1},{2,1},{-1,2},{1,2}};int t, p, q, cas;int mp[27][27];int dfs(int x, int y, int ste原创 2015-08-05 20:54:58 · 259 阅读 · 0 评论 -
POJ-1979 Red and Black
#include #include #include using namespace std;const int maxn = 21;char room[maxn][maxn];int sign[maxn][maxn];int stp[4][2] = {{0,1}, {0,-1}, {-1,0}, {1,0}};int w, h, ans;struct Room{原创 2015-08-07 15:59:04 · 333 阅读 · 0 评论 -
POJ-2456 Aggressive cows
#include #include #include using namespace std;int n, c;const int maxn = 1000010;long long lx[maxn];int main(){ while(cin >> n >> c) { for(int i = 0; i < n; i++)原创 2015-07-27 17:03:57 · 291 阅读 · 0 评论 -
POJ-3258 River Hopscotch
#include #include using namespace std;int L, n, m;const int maxn = 50050;int lx[maxn];int main(){ while(cin >> L >> n >> m) { lx[0] = 0; for(int i = 1; i < n + 1; i++)原创 2015-07-27 10:39:01 · 367 阅读 · 0 评论 -
POJ-2739 Sum of Consecutive Prime Numbers
#include #include using namespace std;int main(){ int n; int a[10000]; int k = 0; for(int m = 2;m <= 10000;m++) { int t = 1; for(int i = 2;i*i <= m;i ++)原创 2015-07-18 17:10:45 · 340 阅读 · 0 评论 -
POJ-1562 Oil Deposits
#include #include #include using namespace std;const int maxn = 100 + 5;char maze[maxn][maxn];int m, n, step;void dfs(int x, int y){ maze[x][y] = '*'; int nx, ny; for(int dx = -原创 2015-08-11 11:17:02 · 261 阅读 · 0 评论 -
POJ-2386 Lake counting
#include #define maxn 110char field[maxn][maxn];using namespace std;void dfs(int i, int j, int n, int m){ field[i][j]='.'; for(int dx = -1; dx <= 1; dx++) { for(int dy = -1; d原创 2015-07-20 15:49:06 · 306 阅读 · 0 评论 -
POJ-5339 Untitled
#include #include #include using namespace std;const int maxn = 21;int num[maxn];int t, n, a, cnt;int main(){ cin >> t; while(t --) { cin >> n >> a; for(int i =原创 2015-08-05 21:13:12 · 216 阅读 · 0 评论 -
POJ-2253 Frogger
#include <iostream>#include <cstdio>#include <cstring>#include <cmath>#include <algorithm>using namespace std;const int maxn = 40000 + 5;int n, pos;double max_len;struct coordinate{ int x,原创 2015-08-31 02:04:29 · 285 阅读 · 0 评论 -
POJ-1797 Heavy Transportation
#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>using namespace std;const int maxn = 1000 + 5;int t, n, m, ans;struct node{ int op; int ed; int len; bool原创 2015-08-31 23:06:39 · 342 阅读 · 0 评论 -
POJ-1064 Cable master
#include #include using namespace std;const int maxn = 10010;int l[maxn];int main(){ int n, k, Max = 0; while(cin >> n >> k) { for(int i = 0; i < n; i++) {原创 2015-07-23 17:48:19 · 293 阅读 · 0 评论 -
POJ-2387 Til the Cows Come Home
#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>using namespace std;const int maxn = 1005;const int INF = 99999;int graph[maxn][maxn];int root[maxn];int sign[maxn];int原创 2015-08-30 21:10:57 · 216 阅读 · 0 评论 -
POJ-3006 Dirichlet's Theorem on Arithmetic Progressions
#include using namespace std;const int maxn = 1000000;int num[maxn];int main(){ int a,d,n; while(cin >> a >> d >> n) { if(!a && !d && !n) break; int i =原创 2015-07-22 11:37:26 · 307 阅读 · 0 评论 -
POJ-2262 Goldbach's Conjecture
#include #include int judge(int m){ for(long long i = 2; i * i <= m; i++) if(m % i == 0) return 0; return 1;}using namespace std;int main(){ int n,i,j; wh原创 2015-07-19 11:11:33 · 325 阅读 · 0 评论