摘要: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=11&problem=1832&mosmsg=Submission+received+with+ID+13415943感觉博弈题写的很纠结。。。这题换了几种姿势,首先双方都是足够聪明的,那么他们一定让自己的优势都足够大。那么我们用DP(l,r)来表示先手能得到的最大分差,那么ans=max(当前选手选择的得分-在他后面的作为先手的最大分差) 1 #include 2 阅读全文
posted @ 2014-03-30 14:56 wonderzy 阅读(253) 评论(0) 推荐(0) 编辑
摘要: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=&problem=1743&mosmsg=Submission+received+with+ID+13398732贪心的思路很明显,每次选择点权最小的走,一边走一边记录路径,很容易想到如果出现环,那么之后没有记录到路径的点就不可能到达了,因为它会不断绕环走于是想到记录点有没有被访问,但是这样做就掉坑里了,如下图起点是0那么4 的路径就是0->1->2-& 阅读全文
posted @ 2014-03-27 17:25 wonderzy 阅读(300) 评论(0) 推荐(0) 编辑
摘要: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=11&page=show_problem&problem=2629好久没写博客了,随便捡道有点意思的题目写写。首先a,b的范围都到unsigned long long了有木有,最后f(a^b)还要再mod上n那么看到n的范围才1000,f(x)的递推式又有了,很容易就想到周期这东西。那么对a^b用快速幂的话,nice~剩下来的就是水水的东西了。。。#include #include #include #inc 阅读全文
posted @ 2014-03-19 16:03 wonderzy 阅读(310) 评论(0) 推荐(1) 编辑
摘要: 题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=11&page=show_problem&problem=1545#include #include #include #include #include #define ll long longusing namespace std;int change[12][12];ll w[12][12],dp[11][11][11][11][11][11];bool vis[12];int a[12];v 阅读全文
posted @ 2014-02-09 20:57 wonderzy 阅读(132) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=11&page=show_problem&problem=1059此题的状态即为4个栈的顶部元素的位置#include #include #include #include #include #include #define ll long longusing namespace std;stack st[5];vector v[5];int n,num;ll dp[42][42][42][42]; 阅读全文
posted @ 2014-02-09 20:55 wonderzy 阅读(159) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=11&page=show_problem&problem=1629水题记忆化dp#include #include #include #define ll long longusing namespace std;int t,n,k;ll a[1010];ll dp[1100][1100];ll DP(int x,int y){ if(x+1==y) return 2*min(a[x],a[y]); 阅读全文
posted @ 2014-02-09 20:51 wonderzy 阅读(159) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=11&page=show_problem&problem=1567此题状态即为各种硬币个数,然后分类讨论即可。#include #include #include using namespace std;int t;int num, n[3], dp[705][220][100], vis[705][220][100];int dfs(int num, int n1, int n2, int n3) 阅读全文
posted @ 2014-02-09 20:50 wonderzy 阅读(217) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=11&page=show_problem&problem=1853#include #include #include using namespace std;int l,s;int dp[30][400][30];int DP(int x,int y,int z){ if(dp[x][y][z]!=-1) return dp[x][y][z]; if(x!=0&&y==0) ret 阅读全文
posted @ 2014-02-09 20:49 wonderzy 阅读(159) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=11&page=show_problem&problem=1342#include #include #include #define ll long longusing namespace std;char s[50];ll dp[50][50];int f(int x){return x>=0 ? x:(-x);}int to(char s){ if(s>='0'&a 阅读全文
posted @ 2014-02-09 20:48 wonderzy 阅读(132) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=11&page=show_problem&problem=643#include #include #define ll long longusing namespace std;int n,m;ll dp[30][30][2],ans;bool vis[30];ll DP(int l,int v,int c){ if(dp[l][v][c]!=-1) return dp[l][v][c]; if( 阅读全文
posted @ 2014-02-09 20:47 wonderzy 阅读(233) 评论(0) 推荐(0) 编辑