自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

Collider

愿所有刷过的题都成为你比赛中信手拈来的水题.

  • 博客(21)
  • 收藏
  • 关注

原创 POJ3320-Jessica's Reading Problem

反复推进区间的开头和末尾,来求取满足条件的最小区间的方法叫做尺取法。 这道题就可以用尺取法很好的求解。#include <cstdio>#include <set>#include <map>#include <algorithm>using namespace std;const int maxp = 1000000;int a[maxp];int main(int argc, char

2016-07-30 08:46:40 213

原创 POJ3061-Subsequence

首先是一个nlogn的解法:#include <cstdio>#include <cstring>#include <algorithm>using namespace std;const int maxn = 100000+5;int num[maxn];int sum[maxn];int main(int argc, char const *argv[]) { int t;

2016-07-29 19:19:15 187

原创 POJ3579-Median

这是一道很难的二分搜索题,稀里糊涂的就AC了还没有弄懂为什么….#include <cstdio>#include <algorithm>using namespace std;const int maxn = 100000+5;int x[maxn];bool judge(int mid, int n, long long c) { int cnt = 0; for (int i

2016-07-29 16:57:44 248

原创 POJ3111-K Best

这道题与POJ2976类似,但是数据量貌似很大....二分最大化平均值#include #include #include using namespace std;const int maxn = 100000;const int inf = 10e6;int v[maxn];int w[maxn];struct rec { double y; in

2016-07-27 19:45:37 283

原创 POJ2976-Dropping tests

http://poj.org/showmessage?message_id=53194在while条件判断时要注意类似1 0的测试样例。#include #include #include using namespace std;const int maxn = 1000+5;const int inf = 10e9;int a[maxn];int b[maxn];d

2016-07-27 15:49:51 258

原创 POJ3045-Cow Acrobats

这是一道贪心的题,找出每头牛排序的方法是关键。当一群牛堆叠起来的时候,从下往上每头牛的risk就是sum-w-s,因此按照w和s之和的大小进行排序即可。#include #include using namespace std;const int maxn = 5*10e4;const int min_risk = -10e9;struct cow { int w,

2016-07-26 15:08:05 244

原创 POJ3104-Drying

首先很难想到用二分,其次判断时要用long long....#include #include using namespace std;const int maxn = 10e5+10;const int inf = 10e9+10;int a[maxn];bool judge(int mid, int n, int k) { long long minute =

2016-07-26 10:01:23 377

原创 POJ3273-Monthly Expense

二分搜索的思想比较容易了解,但是实现起来却经常有些细节方面的小错误导致wa#include #include using namespace std;const int maxn = 100000+10;int fajo[maxn];bool judge(int x, int n, int m) { int group = 1; int sum = 0;

2016-07-25 12:06:15 192

原创 POJ3258-River Hopscotch

经典的二分,理解起来稍难....#include #include using namespace std;const int maxn = 50000+10;int rock[maxn];bool judge(int x, int n, int m) { int last = 0; for (int i = 1; i < n - m; i++) {

2016-07-23 13:16:45 239

原创 POJ2456-Aggressive cows

通过二分搜索贪心的判断条件是否成立即可。#include #include using namespace std;const int maxn = 100000 + 5;const int inf = 10e9 + 10;int stall[maxn];bool judge(int d, int n, int c) { int last = 0; for

2016-07-22 20:53:24 231

原创 POJ1064-Cable master

题目出的也是十分的坑。数据范围从1meter到100kilometers....解题的思路大致就是二分搜索,次数大概在100次左右。答案输出需要floor(ans*100)/100来避免最后答案四舍五入。#include #include const int maxn = 10000;double cab[maxn];bool judge(double a, int

2016-07-22 19:59:12 394

原创 POJ1995-Raising Modulo Numbers

使用模运算定律和快速幂即可。#include long long mod_pow(long long x, long long n, long long mod) { long long res = 1; while (n > 0) { if (n & 1) { res = res * x % mod; }

2016-07-22 16:56:36 285

原创 POJ3641-Pseudoprime numbers

题目给出两个数p, a,要求根据费马小定理检验p是不是个伪素数。用快速幂来做。另外,不能直接将a^p == a(mod p)化成a^p-1 == 1(mod p)来做,因为转换的条件是a不是p的倍数。(贡献一wa)#include bool isprime(int n) { for (int i = 2; i * i <= n; i++) { if (n %

2016-07-22 16:24:02 183

原创 POJ2395-Out of Hay

最小生成树的又一变形题,寻找最小生成树中的最大权值边。#include #include using namespace std;const int maxn = 2005;const int maxm = 10005;int par[maxn];int rk[maxn];void init(int n) { for (int i = 0; i < n; i++)

2016-07-22 11:20:17 277

原创 POJ2377-Bad Cowtractors

最小生成树的变形题,最大生成树。这道题显然用Kruskal算法可以直接计算最小生成树的值,但是题目需要判断最小生成树是否存在,因此我们引入变量node_num表示树中的节点数。比较树中的节点树与总节点树即可。ps.为什么是单向边?#include #include using namespace std;const int maxn = 1000 + 10;const

2016-07-22 10:33:54 324

原创 POJ1258-Agri-Net

考察最小生成树,只要一个Prim算法即可#include #include using namespace std;const int maxn = 105;const int INF = 10e5+10;int cost[maxn][maxn];int mincost[maxn];bool used[maxn];int prim(int v) { for (i

2016-07-21 15:52:33 212

原创 POJ3268-Silver Cow Party

n头牛要从原来的位置到x位置再回到原先位置,求来回最短路中最长的花费。从x回到原来位置可看作单源最短路,但每头牛到x位置的时间不能间接得出。因此将图取反,可转换为反向后的单源最短路来求。这段代码的不足在于使用的spfa中有两段相似代码,可加以改进后使代码更加简洁。#include #include #include #include #include using names

2016-07-18 21:04:54 228

原创 POJ3259-Wormholes

一个图中有双向边和单向的负边,考虑有没有负圈#include #include const int maxn = 510;const int maxm = 6000;struct edge { int from, to, cost;};edge es[maxm];int d[maxn];bool Bellman_Ford(int v, int e) {

2016-07-18 10:41:54 315

原创 POJ2139-Six Degrees of Cowvin Bacon

题目的意思是在同一电影中每头牛的距离都为1用floyd就能简单的做出来。#include #include using namespace std;const int maxn = 300 + 10;const int inf = 10000;int d[maxn][maxn];int tmp[maxn];void floyd(int n) { for (in

2016-07-10 14:00:33 309

原创 POJ1703-Find them, Catch them

这是一道类似于食物链的并查集题目。#include const int maxn = 10e5 + 10;int par[2 * maxn];int rk[2 * maxn];void init(int n) { for (int i = 0; i < 2 * n; i++) { par[i] = i; rk[i] = 0; }}

2016-07-09 14:06:07 225

原创 POJ1860-Currency Exchange

这道题讲述了城里有几个点能过换钱问能否套利。只要用Bellmen_Ford判断图中是否含有负圈即可。#include #include const int maxn = 100 + 5;const int maxm = 100 + 5;struct Edge { int from; int to; double rate; double com;

2016-07-08 15:12:00 214

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除