自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

奋斗的Die Young

生命不息,奋斗不止!

  • 博客(28)
  • 收藏
  • 关注

原创 nyoj17单调递增最长子序列(N*logN)

题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=17比起O(n ^ 2),O(N * logN)算法采用了二分查找的方法,用一个数组f[]存储最长递增的子序列,maxlen代表它的长度。、f[]已经是有序的数组了,所以二分查找非常省时,下面举个例子,从别人博客上弄得。。。。假设存在一个序列d[1..9] =

2016-03-31 21:24:58 315

原创 NYOJ矩形嵌套

题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=16DAG上的动态规划代码:#include #include #include using namespace std;int e[1005][1005];int N;int n;int a[1005],b[1005];int d[1005]

2016-03-31 18:46:59 329

原创 nyoj42一笔画问题

题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=42先用并查集判断图是否连通,如果不连通,直接输出No如果连通,判断奇数度的顶点的个数是否为0或者2,如果是,输出Yes,反之,输出No代码:#include #include using namespace std;int n;int p,q;

2016-03-30 20:04:26 296

原创 hdu1162Eddy's picture

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1162先计算出每对顶点的距离,然后就是最小生成树的模板。。。。代码:#include #include #include #include using namespace std;#define inf 0x3f3f3f3fdouble dis[105][10

2016-03-30 18:49:52 247

原创 NY27水池数目

题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=27大名鼎鼎的Floodfill漫水填充法(种子填充法),设置一个flag = - 1,搜到一个独立区域,就用它填充,然后--flag; 对图的每个满足条件的点都进行dfs,然后最后处理flag一下 在输出代码:#include #include

2016-03-29 23:01:51 262

原创 NY325zb的生日

题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=325深搜的思想,(剪枝非常重要!!!dfs(i + 1) 就是剪枝了)我的思路是边界分为三种情况,以总重量的一半t为基准1.如果搜到的重量小于t,那就更新最小重量差2.如果相等的话,说明这个西瓜能平分了,然后就看总重量了3.如果大于,更新最小重量差,然后rentur

2016-03-29 22:28:40 353

原创 hdu1735字数统计

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1735这道题是借鉴了网上的某位大神的思路及代码。。我说一下思路:先用ans来存储为0的个数,然后记录下来可能为段尾的行的0个数(在b[]数组里),题中一共说有m段,那么段首 一共有2 * m个没有被污浊的格子,另外,最后一行一定是个段尾,所以ans -= 2 * m,ans -= num

2016-03-28 20:04:35 460

原创 hdu1051Wooden Sticks

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1051简简单单的贪心,竟然错了好几次。。。思路:先排序,按照长度升序,或者重量升序,在查找。。代码:#include #include #include using namespace std;typedef struct{ int length;

2016-03-27 20:44:44 220

原创 hdu2680Choose the best route

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2680反着求。。。代码:#include #include #define inf 0x3f3f3f3f#define maxn 1000int n,m,s;int t;int w[maxn + 5];int map[maxn + 5][maxn +

2016-03-26 20:58:24 227

原创 hdu1249三角形

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1249假设现在已经有了n - 1三角形,那现在放第n个三角形,每条边都与前n - 1个小三角形(角上的)相交,增加区域 (n - 2) + (n - 1)个,三条边都放上去的话就是 3*((n - 2) + (n - 1)) + 3,这个 +3是第n个三角形的3个角,递推公式 f[n] =

2016-03-26 19:34:54 281

原创 hdu1465不容易系列之一

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1465一个错牌公式让我写错了三次,也是醉了。。。错牌思想:当n个编号元素放在n个编号位置,元素编号与位置编号各不对应的方法数用D(n)表示,那么D(n-1)就表示n-1个编号元素放在n-1个编号位置,各不对应的方法数,其它类推.第一步,把第n个元素放在一个位置,比如位置k

2016-03-26 18:33:00 269

原创 hdu1257最少拦截系统

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1257太笨了我。。。#include int f[1005];int main(){ int n; while(~scanf("%d",&n)) { int m = 0; f[1] = 0; wh

2016-03-26 17:52:23 220

原创 hdu2602Bone Collector && POJ3624Charm Bracelet

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2602非常裸的0-1背包。。代码:#include #include #include using namespace std;int t;int f[1005];int v[1005];int w[1005];int main(){

2016-03-25 18:47:40 287

原创 hdu2955Robberies

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2955典型的0-1背包的题,只不过把思路换了一下,把所有银行的钱看作是背包容量,单个的银行的钱看作重量,用f[]数组保存的是不被抓到的概率,最后扫描一下就行了.代码:#include #include #include using namespace std;con

2016-03-25 18:38:55 315

原创 hdu1262寻找素数对

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1262太水了....#include #include #include bool isP(int n){ if(n == 1) return false; int k = sqrt(n); for(int i = 2; i

2016-03-24 19:17:23 348

原创 1256画8

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1256这个题描述有点不清楚,要计算一下高度和6的关系,才是宽度。。。代码#include int down,up,h;char key;int cnt6;void print_horizontal(){ for(int i = 1; i <= cnt6;

2016-03-24 18:29:14 323

原创 hdu1235

更水。。。#include #include #include using namespace std;int a[1005];int main(){ int n; while(~scanf("%d",&n),n) { for(int i = 0;i < n;++i) scanf("%d",&a[i]);

2016-03-24 17:51:47 327

原创 hdu1234开门人和关门人

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1234就是水。。。#include #include #include using namespace std;const int maxn = 1000;struct record{ int starth,startm,starts; int en

2016-03-24 17:46:55 414

原创 hdu1231最大连续子序列

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1231如果做题的时候没有看见K的范围,那么TLE经典代码如下: - -!#include const int Min = -1e9;int a[10005];int n;int main(){ while(~scanf("%d",&n),n) {

2016-03-23 21:32:43 236

原创 hdu1230火星A+B

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1230纯模拟,恶心死我了...#include #include int isP[30] = {0,2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101};int main(

2016-03-23 18:53:05 404

原创 hdu1229A+B

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1229继续水.#include #include int main(){ int a,b,k; while(~scanf("%d%d%d",&a,&b,&k)) { if(!a && !b) break;

2016-03-22 23:53:41 358

原创 hdu1228A+B

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1228水..#include #include char s[100];char s1[100];void cmp(char s1[],int &a){ if(strcmp(s1,"zero") == 0) a = a * 10 + 0;

2016-03-22 23:32:32 460

原创 hdu1205吃糖果(鸽巢原理)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1205鸽巢原理:25只鸽子飞进了24个鸽巢,则至少有一个鸽巢有两个鸽子。这道题就是找出数量最大的那堆糖果,然后判断sum - max(代表总量 - 最大堆数量,也就是剩余糖果的数量) 是否大于 max - 1,如果大于的话,代表可以吃完.因为数量为max的糖果有max - 1 个

2016-03-22 22:52:13 345

原创 hdu1031Design T-Shirt

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1031这道题的坑就在于 序号从1开始 但是 不一定要有1号。。。代码:#include #include #include using namespace std;#define maxn 1000double a[maxn + 3][maxn + 3];in

2016-03-21 20:24:11 241

原创 hdu1022Train Problem I

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1022这是一个进栈和出栈顺序的问题算法思路:1.按进栈的顺序一个一个压进栈中                2.设一个指针j,初始化为0,如果栈顶元素和出栈顺序的第j个元素相等,就做出栈的操作(top--) ,然后j++;(注意:这里是循环删除的,自己想为什么)     

2016-03-21 19:47:08 187

原创 HDU1015Safecracker

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1015看代码就知道这道题有多水代码:#include #include #include using namespace std;char s[20];int target;int a[20];bool cmp(int

2016-03-21 18:21:14 347 1

转载 hdu1010

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1010先说下这个题的坑:      1)要求是正好的时间到达,因为这个坑了很多次WA。。      2)减枝。一个是算最短路径都大于给定时间的,一个是奇偶性的问题,比如(0,0)点到了(1,1)要走偶数步,而到(0,1)要走奇数步,判断一下题目给的时间是否符合,还有一个是dfs写的时

2016-03-17 20:33:28 520

原创 hdu1209Clock

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1209这是个水题,直接计算出角度,在排序,另外在输出的时候注意一下,要不WA。。代码:#include #include using namespace std;struct time{    int h;    int m

2016-03-17 18:52:11 482

空空如也

空空如也

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

TA关注的人

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