自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(19)
  • 收藏
  • 关注

原创 (解题报告) Uva 1616 Caravan Robbers (商队抢劫者)(上凸包+队列+结构体)

去网上搜了这道题,都是暴力二分然后把小数还原为分数。虽然可以这么做但是不太像正解。。。接下来的方法没有用到小数化为分数,而是把分数作为结构体应用。 在朴素的基础上加了斜率优化,使得本解法的速度在UVA上排名第一。(如果加读优的话。。)

2016-01-24 13:03:23 1069

原创 halo world ))) uva 10934 droping water

纯思维题目啊。。。。最关键的是可以测到的楼梯的定义,有可能没用完就已经测到了。#include unsigned long long d[64],n,m,x,y;int main() { //freopen("out.txt","w",stdout); int k; while(scanf("%lld%lld",&n,&m) == 2 && n) { for(int i

2016-03-07 20:33:41 387

原创 poj 1112 uva1627

状态是前i个能凑到的与j最相近的数。/*test case152 3 5 01 4 5 3 01 2 5 01 2 3 04 3 2 1 0*/#include #include #include #include #include #include #define INF 100000000using namespace std;const int

2016-02-25 21:13:36 609

原创 UVA 1218 带状态判断的树形Dp

刘汝佳在书上说了状态转移方程, 嗯是三道题中较难的就动手写了一下。。发现有的状态是无效的, 就去看了刘汝佳的代码, 额使用极大值来表示。。这里也可以特殊判断(比如我) -----用IMPOSSIBLE表示不可能。AC代码。#include #include #include #include #include #define maxn 10010#define IMPO

2016-02-10 19:58:45 423

原创 uva 1625 color length

d[i][j] 表示拿了前i个和前j个后,还所需的“最少费用“。d[m][n] = 0;d[i][j] = res[i][j] + min(d[ i+1 ][ j ], d[ i ][ j+1 ] );计算res可以用一维的,因为每次都可以由前一个推算。代码#include int min(int i, int h) {return i<h?i:h;}int

2016-02-07 14:36:04 326

原创 uva 11536smallest sub-array(滑动窗口)

眼见是个水题,于是就随便了....用数组记录1到k所有数的个数,如果全满就更新ans。 维护L一定不能再右移(既是最优的)。虽然方法不是最好的,但是水题就不要计较了。。。#include #include using namespace std;const int maxn = 1000010;int a[maxn],iooi[120];int main() { a[0]

2016-01-25 21:36:57 389

原创 (中途相遇法)Uva 1618 Weak Key(分段DP+枚举)

枚举四个肯定是不行的,所以要枚举两个,我选择枚举中间的两个数,一个最大,一个最小。另外,两种情况如果将数组翻转过来就可以相互等效,所以我只考虑第一种——2413 (从小到大排序)为什么称为分段呢。。。你将会看到这是有道理的。设l[i][j] 是DP式,若i小于j,可分为data【i】 data【j】两种,若i 大于 j,又可分为data【i】 data【j】两种。并且这些情况都能在

2016-01-25 18:52:59 568

原创 uva 1615 (区间选点)

显然的区间选点问题。。。#include #include #include #define eps 1e-7using namespace std;const int maxn = 10000+10;struct village { double o,l; bool operator < (const village& b) const { return l b.o;

2016-01-24 18:14:22 375

原创 uva 1614 Hell on the Markets(数学相关)

首先证明,对于1到i的序列,可以选出一些数,使其和为1~sum[i]的任意一个数。设这性质对1~n的序列成立, 那么a_n+1 最多是sum[n]+1(当之前全为1时),所以a_n+1 到 a_n+1+sum[n] 的所有数都能被凑出来。显然对于1是成立的,所以原假设成立。。。如果sum【n】 为奇数,那么必无解;如果sum【n】为偶数,因为sum/2可以凑出来,所以必有解。66666

2016-01-24 18:11:00 346

原创 (贪心+栈)UVa 11491 Erasing and Winning

也是贪心的策略,略有不同的是,当前状态影响的是之前的决策。如果当前点比栈顶元素大就擦去栈顶元素,直到擦不了为止。#include #include const int MaxN = 100000 + 20;char s[MaxN];inline int readchar(){ char sh = getchar(); while(sh==' ' || sh == '\n')

2016-01-24 17:57:28 361

原创 uva 1610 Party Games

这是第八章的第二个习题。这是细节上的问题, 想清楚不太难的。。。#include #include using namespace std;string haha[1003];int number;string str,s;char ans[100];void work();int main(){ /*freopen("1610.in","r",stdin); freop

2016-01-24 17:52:27 320

原创 (模拟)uva 220 黑白棋

#include #include #include using namespace std;int board[10][10],xx,yy,queue[9],rear;//player 1 and 2;void print_b() { for(int i=1;i<=8;i++) { for(int m=1;m<=8;m++) printf("%c",board[i][m]?

2016-01-24 17:44:31 708

原创 (模拟) uva 1589 Xiangqi

总体思路: 将不能走的打标记。#include #include #include using namespace std;struct node{ int i,j; char type; }queue[10];char xiangqi[12][11];int beat[11][10],X,Y;void setwall();void mark(char , int ,

2016-01-24 17:41:15 378

原创 (Repeating Decimals) uva 202 需要一些灵感。。。

恩,这是第三章中最有意思的题目了。循环小数要怎么判定? 每次进位都会得到一个余数,如果得到的余数与之前的重复,说明已经出现了循环。这细节有点难写,我以前好像写了一个下午。。。#include #include int main(){/* freopen("stand.txt","r",stdin); freopen("stand2.txt","w",stdout);*/ i

2016-01-24 12:36:49 330

原创 (入门)uva 1368 DNA Consensus String

.............为什么年幼的我这么喜欢用new 和delete 。不过看上去挺不错的。。。。#include #include int tonu(char c){ if(c=='A') return 0; if(c=='C') return 1; if(c=='G') return 2; if(c=='T') return 3;}char toch(int n

2016-01-24 12:27:36 294

原创 纵横字谜的答案(uva 232)

都是网格内的操作,与Puzzle类似。#include #include #include char crossword[12][12];void setwall(int,int);struct cw{ int p1,p2; bool Cross; bool Down;};int main(){ int row,col,kase=0,first=1; while(s

2016-01-24 12:24:02 449

原创 (入门) uva 10340 All in all

后来想了想,好像只用判断字符串s中的字母个数和t中的字母个数,可是初学的我写了个搜索。。。#include #include bool search(char*,char*);int main(){ char ALL[100000],all[100000]; while(scanf("%s%s",all,ALL)!=EOF) { if(search(ALL,all)) p

2016-01-24 12:10:03 307

原创 (入门)uva 227 Puzzle

类似于模拟。。写法可供参考。。。#include #include char puzzle[7][7];int p1,p2;char readchar();void setwall();int move(const char);int main(){ int kase=0,first=1; while(1) { char c,moves[100]; if(

2016-01-24 12:04:27 316

原创 (入门)uva 455

发以前写过的东西。。

2016-01-24 11:57:03 324

空空如也

空空如也

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

TA关注的人

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