上一页 1 ··· 13 14 15 16 17 18 19 20 21 ··· 34 下一页
摘要: /* TASK: hamming LANG: C++ URL:http://train.usaco.org/usacoprob2?a=5FomsUyB0cP&S=hamming SOLVE: 找粗一个值最小的n个元素的集合,每个元素都是不超过m位二进制的数,且两两之间二进制位不同的位不小于d。 dfs,枚举每一个数,枚举范围:(前一个数,1 int n,m,d; int a[1024]; int... 阅读全文
posted @ 2016-09-30 21:22 水郁 阅读(349) 评论(0) 推荐(0) 编辑
摘要: /* TASK: holstein LANG: C++ URL: http://train.usaco.org/usacoprob2?a=SgkbOSkonr2&S=holstein SOLVE: con[i][j]为食物i含有维生素j的量,ned[i]为需要的维生素i的量 bfs,用二进制保存状态 */ #include #define N 30 int v,g,ned[N],con[N][... 阅读全文
posted @ 2016-09-30 19:31 水郁 阅读(328) 评论(0) 推荐(0) 编辑
摘要: /* TASK: sort3 LANG: C++ URL: http://train.usaco.org/usacoprob2?a=RkPIMxsFWzm&S=sort3 SOLVE: n个数的序列,值只有1、2、3,通过几次互换可以变成升序。 num[i][j]为排完序后为数字i,原来是数字j的位置的个数, 所有i!=j的min(num[i][j],num[j][i])就是互换就能到正确位置的... 阅读全文
posted @ 2016-09-30 11:42 水郁 阅读(191) 评论(0) 推荐(0) 编辑
摘要: /* TASK: frac1 LANG: C++ URL: http://train.usaco.org/usacoprob2?S=frac1&a=dbgwn5v2WLr SOLVE: 直接枚举,约分,排序,去重 */ #include #include using namespace std; struct node{ int nu,deno; double v; }a[40... 阅读全文
posted @ 2016-09-29 23:27 水郁 阅读(347) 评论(0) 推荐(0) 编辑
摘要: /* TASK: castle LANG: C++ SOLVE: 深搜,注意每个方向对应值。枚举去掉的墙,然后再dfs,注意墙要复原,并且dfs里要判断是否超出边界。 */ #include #include #include #define N 55 using namespace std; int n,m; int a[N][N]; int ans,num,cnt; int rans,rm... 阅读全文
posted @ 2016-09-29 22:13 水郁 阅读(383) 评论(0) 推荐(0) 编辑
摘要: /* TASK: sprime LANG: C++ SOLVE: dfs,后面每增加一位,判断当前是否为素数。 第一位不能为0 */ #include int n; void dfs(int x,int d){ for(int i=2;i<=x/i;i++) if(x%i==0)return; if(x==1)return; if(d==n){ ... 阅读全文
posted @ 2016-09-29 10:44 水郁 阅读(287) 评论(0) 推荐(0) 编辑
摘要: 1 /* 2 TASK: pprime 3 LANG: C++ 4 SOLVE: 枚举数的长度,dfs出对称的数,判断是否在范围内,是否是素数 5 原来想着枚举每个范围里的数,但是显然超时,范围最大是10^9。 6 对称的数只有9*2+9*9*2+9*9*9*2+9*9*9*9*2个,再加上几个九位数的。 7 共一万多个。 8 n=10000 9 复杂度就是O(根号n)。 10... 阅读全文
posted @ 2016-09-29 10:21 水郁 阅读(271) 评论(0) 推荐(0) 编辑
摘要: /* TASK: milk3 LANG: C++ SOLVE: 倒水,dfs,枚举每一种倒法,ca[i][j]记录a和c桶的状态,因为总体积不变,故b的状态不需要记录。 */ #include #include #include #include using namespace std; int a,b,c; bool ca[30][30]; void dfs(int na,int nb,in... 阅读全文
posted @ 2016-09-28 17:26 水郁 阅读(334) 评论(2) 推荐(0) 编辑
摘要: /* TASK: ariprog LANG:C++ URL:http://train.usaco.org/usacoprob2?a=PA9lOcZrdWq&S=ariprog SOLVE:平方和最大为m*m*2,因此bq数组标记数i是否为平方和数,num数组存第i个平方和数 枚举公差q,从1到num[tol]/(n-1),枚举起点p,从num[1]到num[tol-1] 判断数p+i*q是否为平... 阅读全文
posted @ 2016-09-28 14:44 水郁 阅读(348) 评论(0) 推荐(0) 编辑
摘要: n个点(n<=1000)大小范围[0,100],改变一些点的值,使得极差不超过17,代价为改变值的平方。 枚举修改后的最低高度low,维护最小代价。 阅读全文
posted @ 2016-09-27 18:58 水郁 阅读(448) 评论(0) 推荐(0) 编辑
摘要: /* LANG: C++ TASK: wormhole n个洞,n #include #include using namespace std; #define N 15 int n,to[N],v[N],ans,vis[N]; struct node{ int x,y,id; }a[N]; int cmp(node a,node b){ return a.xn){ ... 阅读全文
posted @ 2016-09-27 16:50 水郁 阅读(223) 评论(0) 推荐(0) 编辑
摘要: /* TASK:combo LANG:C++ URL:http://train.usaco.org/usacoprob2?a=E6RZnAhV9zn&S=combo SOLVE:自己做,想的是5*5*5*2-重复计算的。 官方题解是超级简单地写个判断枚举每一种解是否可行(n^3),题目没给n的范围,我就认为不可以用O(n^3)的算法。 */ #include #include #includ... 阅读全文
posted @ 2016-09-26 17:13 水郁 阅读(260) 评论(0) 推荐(0) 编辑
摘要: [ HDU 5878 ] I Count Two Three 考虑极端,1e9就是2的30次方,3的17次方,5的12次方,7的10次方。 而且,不超过1e9的乘积不过5000多个,于是预处理出来,然后每次二分找就可以了。 1 /* 2 TASK:I Count Two Three 2^a*3^b 阅读全文
posted @ 2016-09-18 03:13 水郁 阅读(575) 评论(0) 推荐(0) 编辑
摘要: 贪心,去掉最大的min(m,c)-1个间隔 阅读全文
posted @ 2016-09-09 15:59 水郁 阅读(390) 评论(0) 推荐(0) 编辑
摘要: 进制转换,然后判断是否是回文 阅读全文
posted @ 2016-09-07 22:59 水郁 阅读(528) 评论(0) 推荐(0) 编辑
上一页 1 ··· 13 14 15 16 17 18 19 20 21 ··· 34 下一页
……