11 2014 档案

hdu5113 dfs+强有力剪枝(将颜色放满格子)
摘要:注意到,只要在搜索过程中出现一种颜色大于剩下格子/2,必然不用继续向下搜索。 1 #include 2 #include 3 #include 4 using namespace std; 5 int d[105][105],c[105]; 6 int n,m,k,temp; 7 int judge... 阅读全文

posted @ 2014-11-30 14:28 xiao_xin 阅读(156) 评论(0) 推荐(0)

hdu5115 区间dp(杀死所有狼最小代价)
摘要:dp[i][j]=min(dp[i][k-1]+dp[k+1][r]+b[l-1]+b[r+1]+a[k]);k指这个区间杀的最后一只 1 #include 2 #include 3 #include 4 using namespace std; 5 int dp[205][205],a[205],... 阅读全文

posted @ 2014-11-30 10:59 xiao_xin 阅读(215) 评论(0) 推荐(0)

poj2546 两圆相交模板(不错的模板get)
摘要:1 #include 2 #include 3 #include 4 #include 5 #define pi 3.1415926535897932384626433832795 6 using namespace std; 7 double area(double x1,double y1,d... 阅读全文

posted @ 2014-11-29 00:02 xiao_xin 阅读(171) 评论(0) 推荐(0)

hdu3709 数位dp六(左权重等于右权重的数)
摘要:和五类似,此题枚举的是平衡位置,然后依旧数位dp只要从头dfs到尾权重为0即符合。注意0每一次都被重复计算了。 1 #include 2 #include 3 long long dp[20][1800][20]; 4 int num[20]; 5 long long dfs(int pos,int... 阅读全文

posted @ 2014-11-28 22:51 xiao_xin 阅读(174) 评论(0) 推荐(0)

hdu4389 数位dp五(能被各位数之和整除)
摘要:所有位和最大为81,枚举x为1-81即和为x且该数能被x整除。。卡内存过=== 1 #include 2 #include 3 int num[15]; 4 int dp[11][82][82][82]; 5 int dfs(int pos,int sum,int lsum,int mod,int ... 阅读全文

posted @ 2014-11-28 19:32 xiao_xin 阅读(220) 评论(0) 推荐(0)

hdu3652数位dp四 (数是13的倍数且包含13)
摘要:相比第一个数位dp,多加了一维mod,来判定前面值对13的取模,知道最后返回结果要两个都成立。 1 #include 2 #include 3 int num[15]; 4 int dp[15][15][15][2]; 5 int dfs(int pos,int pre,int mod,int ha... 阅读全文

posted @ 2014-11-28 01:44 xiao_xin 阅读(230) 评论(0) 推荐(0)

CodeForces 55D 数位dp三(某数能被它每位数整除)
摘要:dfs(pos,sum,nlcm,flag)pos表示到第几位;sum表示前几位表示的数,因为太大可以mod所有数的最小公倍数2520;nlcm表示前几位的最小公倍数,最大只有2520,但还是太多需要离散化;flag表示有没有上限。dp[pos][sum][nlcm]; 1 #include 2 #... 阅读全文

posted @ 2014-11-27 23:15 xiao_xin 阅读(303) 评论(0) 推荐(0)

hdu2089 数位dp二(不含62或者4)
摘要:递推的写法,进一步理解了数位dp,为了防重复计算总是比当前上限小的。 1 #include 2 #include 3 int dp[10][5],num[10]; 4 int cal(int x) 5 { 6 int tmp=x,i,cnt,ans,flag; 7 memset(nu... 阅读全文

posted @ 2014-11-27 18:48 xiao_xin 阅读(123) 评论(0) 推荐(0)

hdu3555 数位dp一:不含49的数
摘要:首先递推公式:dp[i][0] = dp[i-1][0] * 10 - dp[i-1][1];// 不含49dp[i][1] = dp[i-1][0];// 不含49以9开头dp[i][2] = dp[i-1][2] * 10 + dp[i-1][1];// 含49然后从高位往低位递推,ans+=d... 阅读全文

posted @ 2014-11-27 16:23 xiao_xin 阅读(125) 评论(0) 推荐(0)

2014苏州大学新生赛11月新生赛简单题解
摘要:比赛场链接:http://acm.hdu.edu.cn/diy/contest_show.php?cid=25601对于本次新生赛感觉还是挺满意的(萌萌哒),题目挺好(除了个别坑),榜单挺好看,我们的新生做的和我预期差不多,希望大家能再接再厉,无论好与不好,继续加油!不废话啦,题解写上:前四道题目是... 阅读全文

posted @ 2014-11-27 01:05 xiao_xin 阅读(267) 评论(0) 推荐(0)

CodeFoces 489E 01分数规划(二分的dp)
摘要:关于01分数规划:http://www.cnblogs.com/perseawe/archive/2012/05/03/01fsgh.html算法很好,比较巧妙,尚未能深入理解。 1 #include 2 #include 3 #include 4 #include 5 using namespac... 阅读全文

posted @ 2014-11-22 00:24 xiao_xin 阅读(161) 评论(0) 推荐(0)

CodeForces 489F dp[][]
摘要:将每列0和1数目切出来然后根据组合数来dp一直推到dp[0][0],即列有0个1的木有了,列有1个1的木有了== 1 #include 2 #include 3 long long dp[505][505],x[505][505]; 4 int main() 5 { 6 int n,m,i,... 阅读全文

posted @ 2014-11-20 16:02 xiao_xin 阅读(221) 评论(0) 推荐(0)

acm计划(更新于2014.11.9)
摘要:下面有:1.要学习的知识:(主要) 图论:2-SAT,DLX,强联通tarjan,最小费用流 字符串:AC自动机 数据结构:划分树,伸展树spaly,动态树lct,主席树,平衡树treap,树的重心和直径 dp:概率dp及期望,插头dp 数论:高斯消元2.各个比赛要继续勇敢地被虐,为了未来... 阅读全文

posted @ 2014-11-09 16:41 xiao_xin 阅读(127) 评论(0) 推荐(0)

hdu5101 m个集合取任意不同集合两个数和大于k的方案:stl二分
摘要:1 #include 2 #include 3 #include 4 using namespace std; 5 #define LL long long 6 LL f[1005],a[1005][105],b[1000005]; 7 int main() 8 { 9 LL n,k,i,... 阅读全文

posted @ 2014-11-09 00:19 xiao_xin 阅读(126) 评论(0) 推荐(0)

hdu5102 单位边权树上的前k长路径和:队列技巧
摘要:单向拓展边orz题解== 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 int next[200005],head[200005],point[200005],now; 7 void add(int x,in... 阅读全文

posted @ 2014-11-09 00:14 xiao_xin 阅读(236) 评论(0) 推荐(0)

hdu3518 后缀数组标准模板:出现两次及以上子串数目
摘要:字符串最后切记别忘了加上一个与前面不同的小标志!!然后此题还是利用height函数把每一个所枚举的长度为i的重复串个数计算出来,然后多少个不同的ans++ 1 #include 2 #include 3 #include 4 using namespace std; 5 char s[200005]... 阅读全文

posted @ 2014-11-08 01:26 xiao_xin 阅读(118) 评论(0) 推荐(0)

hdu1403 后缀数组模板 求最长公共子串
摘要:用一个未用过的字符连接两个字符串,求后缀数组相邻项来自不同穿的--最大height值即可。 1 #include 2 #include 3 #include 4 using namespace std; 5 char s[200005]; 6 7 int sa[200005],t[200005],... 阅读全文

posted @ 2014-11-07 22:07 xiao_xin 阅读(102) 评论(0) 推荐(0)

hdu1573 中国剩余定理
摘要:从爱神那看的中国剩余定理解法,挺容易理解的,就是一个循环迭代更新下去细节还是很重要! 1 #include 2 #include 3 #define LL long long 4 void exgcd(LL a,LL b,LL& d,LL &x,LL &y) 5 { 6 if (!b) {d... 阅读全文

posted @ 2014-11-07 12:13 xiao_xin 阅读(104) 评论(0) 推荐(0)

hdu4790 分别在两区间内各取一个数使模p为m的方案
摘要:想到了用容斥简化题目,也想倒如何去算大区间的方案,最后对两个遗留串处理纠结了太久!!帅bin ac后我看了别人题解,真的只是细节讨论那儿处理的失误TAT哎自己傻逼又没写出来! 1 #include 2 #include 3 #include 4 using namespace std; 5 #def... 阅读全文

posted @ 2014-11-07 01:16 xiao_xin 阅读(117) 评论(0) 推荐(0)

hdu4786 生成树中1的个数为fibonacci数
摘要:为什么在最小值和最大值之间就行,模模糊糊== 1 #include 2 #include 3 #include 4 using namespace std; 5 int father[100005],f[30]; 6 struct dian{ 7 int x,y,w; 8 }a[100005... 阅读全文

posted @ 2014-11-06 22:37 xiao_xin 阅读(116) 评论(0) 推荐(0)

hdu1452 积性函数(+逆元,快速幂)
摘要:积性函数定义:f(1)=1,当a,b互质时f(ab)=f(a)f(b)。eg:1.f[n]:n的正因子个数 2.f[n]:n的正因子之和 3.gcd(n,k) k固定时n与k的最大公约数 4.φ(n) n的欧拉函数值(即小于n且与n互质数的数目)此题满足第二个,即可拆分成几个素数,然后用等比数... 阅读全文

posted @ 2014-11-06 16:16 xiao_xin 阅读(193) 评论(0) 推荐(0)

hdu1500 选n个3组合数,时两小差平方总和最小
摘要:先按从大到小排序。。没想到。这样动态方程比较好想了dp[i][j]=min(dp[i][j-1],dp[i-1][j-2]+(a[j]-a[j-1])*(a[j]-a[j-1])); j>=3i+1当j=3i时只能选后一个。 1 #include 2 #include 3 #include 4 u... 阅读全文

posted @ 2014-11-05 23:35 xiao_xin 阅读(155) 评论(0) 推荐(0)

hdu1494 二维dp表示到i段还有j个能量槽
摘要:1 #include 2 #include 3 #include 4 using namespace std; 5 int a[10005],b[10005]; 6 int dp[10005][20]; 7 int main() 8 { 9 int n,k,i,j,cnt;10 w... 阅读全文

posted @ 2014-11-05 21:51 xiao_xin 阅读(109) 评论(0) 推荐(0)

hdu1493 概率dp(掷色子n次到定点概率)
摘要:1 #include 2 #include 3 #define eps 1e-8 4 int a[]={5,12,22,29,33,38,42,46,50,55}; 5 double d[15],dp[105]; 6 int main() 7 { 8 int T,i,j,k; 9 ... 阅读全文

posted @ 2014-11-05 21:42 xiao_xin 阅读(391) 评论(0) 推荐(0)

hdu4512 最长公共上升子序列(LCIS)
摘要:关于最长公共上升子序列,dp[i][j]表示对应a[i],b[j]的以b[j]结尾的LCIS。转移方程:a[i]!=b[j]: dp[i][j]=dp[i-1][j]a[i]==b[j]: dp[i][j]=max(dp[i-1][k])+11b[k]显然这是n3转移,只是该算法巧在加了一个max... 阅读全文

posted @ 2014-11-05 14:29 xiao_xin 阅读(105) 评论(0) 推荐(0)

hdu5097(上海邀请赛I) 拓扑序(双队列)+(输入略复杂)
摘要:最小重启==打代码还是不仔细! 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 using namespace std; 8 mapmp; 9 queueq1,q2; 10 int next[2... 阅读全文

posted @ 2014-11-04 23:43 xiao_xin 阅读(170) 评论(0) 推荐(0)

hdu5094(上海邀请赛E) 状态压缩bfs:取钥匙开门到目的地
摘要:貌似和前段时间的一场网络赛一个类型,状态压缩判断走没走过,然后裸bfs到终点。其实这类题目很简单就是一个bfs模板,无非就是有一些坑,比如这一题。。一个格子可以有多把钥匙汗== 1 #include 2 #include 3 #include 4 #include 5 using namespace... 阅读全文

posted @ 2014-11-02 19:54 xiao_xin 阅读(122) 评论(0) 推荐(0)

hdu5091(上海邀请赛B) 线段树+扫描线:求固定大小矩形内最多点个数
摘要:过几天再看看别人怎么做的。。我是根据以前做的一道题目想到的思路,将某点变为2条线,该点是第一条线下面,线值为1,另一点在右边那条线下面,值为-1然后区间修改求最大值。。 1 #include 2 #include 3 #include 4 using namespace std; 5 int tmp... 阅读全文

posted @ 2014-11-02 17:30 xiao_xin 阅读(288) 评论(0) 推荐(1)

hdu1227 n个站点建m个餐厅使(每个站点到他最近的餐厅)和最小
摘要:前i个站点建j个餐厅=min(前k个站点建j-1个餐厅+最后一个餐厅必然建在a[(k+1+i)/2]的位置) (j-1 2 #include 3 #include 4 #include 5 using namespace std; 6 int dp[205][35],cost[205][205],a... 阅读全文

posted @ 2014-11-01 14:17 xiao_xin 阅读(103) 评论(0) 推荐(0)

hdu1466 dp:直线可能交点数
摘要:i,j,k有j条自由,剩下i-j条相互平行,[j][k]状态表示是否可行 1 #include 2 #include 3 int dp[25][200]; 4 int main() 5 { 6 int i,j,k,n,flag; 7 memset(dp,0,sizeof(dp)); ... 阅读全文

posted @ 2014-11-01 09:34 xiao_xin 阅读(68) 评论(0) 推荐(0)

hdu1428 递归形式dp(记忆化搜素):A能到B的条件是A到目的地最短路大于B到目的地最短路
摘要:自以为已经做了好多年dp,可最近随意一个dp放在眼前却总是不能想到!!先用bfs(队列)处理每个点到目的地最短路,不用转化为图用dijkstra,麻烦且超时。然后记忆化搜素,对于起始点,四个方向若有到达目的地最短路小于当前点,则起始点的方案数+=该方向点到目的地方案数。 1 #include 2 #... 阅读全文

posted @ 2014-11-01 08:41 xiao_xin 阅读(157) 评论(0) 推荐(0)

hdu1501 dp:两个字符串能否组成新串,状态表示能,不能。
摘要:dp思路最重要!! 1 #include 2 #include 3 char s1[1005],s2[1005],s[1005]; 4 int dp[1005][1005]; 5 int main() 6 { 7 int T,t,i,j,len1,len2; 8 scanf("%d"... 阅读全文

posted @ 2014-11-01 01:13 xiao_xin 阅读(162) 评论(0) 推荐(0)

导航