
算法入门经典第二版第八章高效算法设计
文章平均质量分 62
MrFox_
1.少说话, 多做事。
2.现在就是将来, 本来现实, 何必幻想!
展开
-
UVA - 11491 Erasing and Winning
//在满足要求的情况下找已经选出的答案。//#include#include#includeusing namespace std;const int maxn = 1e5 + 5;int vis[maxn];int main(){ int n, d; while(scanf("%d%d", &n, &d) == 2 && (n||d)) {原创 2015-06-08 16:24:41 · 397 阅读 · 0 评论 -
UVA 1605 Building for UN
#include#include#include#include#includeusing namespace std;char s[] = {'0', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S','T', 'U', 'V', 'W','X',原创 2015-08-29 09:57:06 · 440 阅读 · 0 评论 -
UVA 1152 4 Values whose Sum is 0
//核心是学长的一个牛逼的hash标记。看到了学长们去年的态度, 自愧不如。#include#include#include#include#includeusing namespace std;const int maxn = 4000 + 5;struct Hash_map{ static const int mask = 0x7fffff; int p[8原创 2015-08-31 09:30:47 · 458 阅读 · 0 评论 -
UVA 120 Stacks of Flapjacks (STL deque&reverse)
#include#include#include#include#include#include#include#includeusing namespace std;deque res;int Is_order(){ for(int i = 0; i < (int)res.size() - 1;++i) if(res[i] > res[i+1]原创 2015-09-02 10:56:04 · 468 阅读 · 0 评论 -
UVA 1149 Bin packing
//重做这个题完全是为了使用res.erase();以前比赛的时候基本不敢用, 事实证明是可以A题的;不能res.erase(res.end());不知为何。。。#include#include#include#include#include#includeusing namespace std;vector res;int main(){ int n;原创 2015-09-01 20:40:32 · 456 阅读 · 0 评论 -
UVA 1612 Guess
注意精度问题;set里面的count是不能避免精度问题的;原创 2015-09-01 19:30:06 · 483 阅读 · 0 评论 -
UVA - 11134 Fabled Rooks
#include#include#include#include#includeusing namespace std;const int maxn = 5000 + 5;struct node{ int x1, x2, y1, y2; int id;}k[maxn];int x[maxn];int y[maxn];bool cmp1(node p, nod原创 2015-09-10 15:47:20 · 411 阅读 · 0 评论