自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

转载 动态规划专题 01背包问题详解【转】

http://www.cnblogs.com/fancy-itlife/p/4393213.html动态规划专题 01背包问题详解【转】         对于动态规划,每个刚接触的人都需要一段时间来理解,特别是第一次接触的时候总是想不通为什么这种方法可行,这篇文章就是为了帮助大家理解动态规划,并通过讲解基本的01背包问题来引导读者如何去思考动态规划。本文力求

2016-11-05 18:42:02 385

转载 动态规划专题 01背包问题详解 HDU 2546 饭卡

http://www.cnblogs.com/fancy-itlife/p/4394398.html动态规划专题 01背包问题详解 HDU 2546 饭卡我以此题为例,详细分析01背包问题,希望该题能够为大家对01背包问题的理解有所帮助,对这篇博文有什么问题可以向我提问,一同进步^_^饭卡Time Limit: 5000/1000

2016-11-05 18:40:31 383

转载 kmp算法

前言    之前对kmp算法虽然了解它的原理,即求出P0···Pi的最大相同前后缀长度k;但是问题在于如何求出这个最大前后缀长度呢?我觉得网上很多帖子都说的不是很清楚,总感觉没有把那层纸戳破,后来翻看算法导论,32章 字符串匹配虽然讲到了对前后缀计算的正确性,但是大量的推理证明不大好理解,没有与程序结合起来讲。今天我在这里讲一讲我的一些理解,希望大家多多指教,如果有不清楚的或错误的请给我留

2016-10-23 15:44:02 362 1

转载 输入优化

点击打开链接

2016-10-12 20:05:09 272

原创 codeforces 697B. Barnicle - 字符串变数字

科学计数法 给出 a.deb 的形式 转化为数字 要考虑的情况真的好多 QAQ#include #include #include #include #include #include #include #include using namespace std;#define PI 3.1415926 int main(){ string str; int s

2016-09-27 14:11:24 224

原创 字典数查找字串

#include #include using namespace std; struct node{ int num; //记录多少单词途径

2016-08-20 15:34:48 268

转载 hdu1863-畅通工程 最小生成树的并查集实现方法

hdu1863 ←杭电的域名换掉了,之前贴的链接都打不开Problem Description省政府“畅通工程”的目标是使全省任何两个村庄间都可以实现公路交通(但不一定有直接的公路相连,只要能间接通过公路可达即可)。经过调查评估,得到的统计表中列出了有可能建设公路的若干条道路的成本。现请你编写程序,计算出全省畅通需要的最低成本。

2016-08-18 16:08:14 231

原创 hdu2553-N皇后问题 DFS

2553  横着竖着斜着都不能有两个皇后“也不允许处在与棋盘边框成45角的斜线上。”容易被这句话欺骗成以为是棋盘的两条对角线,是任意的棋子的斜方向不能有其他的皇后 思路:先确定第一行再往下递归不打表的代码,容易理解一点点嘻嘻↓#include #include #include #include using namespace std;char map[12][1

2016-08-16 21:59:06 324

原创 hdu1372-Knight Moves BFS

1372求从他给的坐标走到另一个坐标需要多少步数,字母数字代表行列走的规则就像马走日一样(可以先横走一步再竖两步,或者竖两步横一步一共有八个方向)#include #include #include #include using namespace std; char map[9][9];int judge[9][9];int s1,s2,e1,e

2016-08-16 09:56:19 230

原创 hdu1548-A strange lift BFS

1548Sample Input5 1 5 //5层楼 当前位置1楼 目标5楼3 3 1 2 5 //1楼只可以按3,不能再下,到了4楼;4楼只能按2,到了2楼;2楼按3到了五楼0 Sample Output3 // 最少按了3次键#include #include #i

2016-08-16 09:41:53 304

转载 hdu1166-敌兵布阵 线段树

Problem DescriptionC国的死对头A国这段时间正在进行军事演习,所以C国间谍头子Derek和他手下Tidy又开始忙乎了。A国在海岸线沿直线布置了N个工兵营地,Derek和Tidy的任务就是要监视这些工兵营地的活动情况。由于采取了某种先进的监测手段,所以每个工兵营地的人数C国都掌握的一清二楚,每个工兵营地的人数都有可能发生变动,可能增加或减少若干人手,但这些都逃不过C国的监视

2016-08-14 16:12:45 188

转载 hdu1556-color the ball 线段树

1556Sample Input3 //三组数1 1 //涂气球的区间2 23 331 11 21 30 Sample Output1 1 1 //第一个气球被涂1次颜色 第二个气球被涂2次颜色 第三个气球被涂3次颜色3 2 1#include #include using namespace

2016-08-13 17:38:44 197

转载 线段树入门

1、概述线段树,也叫区间树,是一个完全二叉树,它在各个节点保存一条线段(即“子数组”),因而常用于解决数列维护问题,它基本能保证每个操作的复杂度为O(lgN)。2、线段树基本操作线段树的基本操作主要包括构造线段树,区间查询和区间修改。(1)    线段树构造首先介绍构造线段树的方法:让根节点表示区间[0,N-1],即所有N个数所组成的一个区间,然后,

2016-08-09 18:57:50 458

原创 hdu1213-有多少桌子 并查集

1213  A认识B,B认识C,就相当于ABC都认识,便可以坐在一张桌子上 输入T组数,有N个人,再输入M对人关系可是为什么WA???↓ #include using namespace std; int pre[1011]; int find(int x){ return pre[x]!=x?find(pre[x]):x;}void join(int

2016-08-08 17:22:02 356

原创 hdu1272-小希的迷宫 并查集

1272成迷宫条件:不成环,只有一个父节点(没有孤立的点)#include using namespace std; int pre[100001]; bool t[100001],flag; //t 用于标记独立块的根结点,flag标记成环 int max1;void init(){ max1 = 0; flag =

2016-08-08 16:08:23 218

原创 hdu1013-字符相加

1013 输出的数必须是一位数,24 = 2+4 =639 = 3+9  =12,12 = 1+2 =3 所以输出3--------------------------------------------------------------------------------------------------------------------------------------

2016-08-05 15:53:08 499

转载 并查集详解

转自转自点击打开链接这个文章是几年前水acm的时候转的, 当时也不知道作者是谁, 要是有人知道的话说一下吧并查集是我暑假从高手那里学到的一招,觉得真是太精妙的设计了。以前我无法解决的一类问题竟然可以用如此简单高效的方法搞定。不分享出来真是对不起party了。(pa

2016-08-03 16:59:55 518

原创 hdu1402-大数相乘

1402。。又超时了 QAQ#include #include using namespace std; string pre(string &a) { int i = 0; if (a[0]!='0') return a; while (a[i] == '0') i++; a = a.substr(i,a.length()-1);

2016-08-02 20:16:05 342

原创 hdu1002-大数相加

1002#include #include using namespace std; string pre(string &a){ int i = 0; if (a[0]!='0') return a; while (a[i] == '0') i++; a = a.substr(i,a.length()-1); //删除前面的0,如00

2016-08-02 12:26:01 244

原创 hdu1035-模拟问题 机器人走迷宫

1035自己写的超时了↓,不知道怎样计算循环的步数搜了别人代码,好厉害啊。。。(′へ`、 )#includeusing namespace std; int main() { int mark[12][12] = {0}; char map[12][12]; int m,n,q,x,y,p,f; bool isloop = false; while(cin>>m>>n

2016-07-29 10:53:09 411

原创 hdu1251-字符前缀查找问题 map容器

1251#include<iostream>#include<string>#include<map>using namespace std;int main(){ string str,str1; map<string, int> map1; while(getline(cin, str)&& str.length() !=0) { for(int i = 1; i != str.size()+1; i++)

2016-07-26 21:28:00 410

原创 hdu1113-字符查找问题 map容器

1113#include #include #include #include using namespace std;int main(){ map map1; map ::iterator it; string str1,str,str2; while (cin>>str && str.compare("XXXXXX")!=0) { str1 = str

2016-07-26 17:21:37 317

转载 c++map的用法

1. map最基本的构造函数;mapmapstring; mapmapint;mapmapstring; mapmapchar;mapmapchar; mapmapint;2. map添加数据;mapmaplive;1. maplive.insert(pair(102,"aclive"));2. maplive.insert(map::value_type(32

2016-07-26 15:12:13 257

原创 hdu1201-日期问题

1201#include #include using namespace std;int isleap(int a){ if(a%4 == 0 && a%100 !=0 || a%400 == 0) return 366; else return 365; }int main(){ int t,year,month,day,sum; while (cin>>t)

2016-07-26 14:24:47 452

原创 hdu1200-二维数组问题

1200题意有点难懂(´⌒`。)  t o i o y          --------→                      |    |h p k n n        ←--------                      |    |e l e a i          --------→                      |    |

2016-07-25 15:48:02 291

原创 hdu2502-月之数 注意int double范围

2502错点:要先变成double再变成int输出才不WA#include #include using namespace std;int main() { int t,n; while (cin>>t) { while (t--) { cin>>n; double

2016-07-25 09:31:01 176

原创 hdu2057-进制转换问题

点击打开链接Sample Input+A -A+1A 121A -9-1A -121A -AA Sample Output02C11-2C-90%d 有符号32位整数%lld 有符号64位整数%llx有符号64位16进制整数%u 无符号32位整数十六进制负数在计算机里

2016-07-23 17:45:41 260

原创 hdu2031-进制转换问题 vector容器

2031Problem Description输入一个十进制数N,将它转换成R进制数输出。 Input输入数据包含多个测试实例,每个测试实例包含两个整数N(32位整数)和R(210)。 Output为每个测试实例输出转换后的数,每个输出占一行。如果R大于10,则对应的数字规则参考16进制(比如,10用A表示,等等)。 Sample Input7 223 12-4 3 Sampl

2016-07-23 10:01:04 313

原创 hdu1877-进制转换问题 vector容器

1877Input输入格式:测试输入包含若干测试用例。每个测试用例占一行,给出m和A,B的值。当m为0时输入结束。 Output输出格式:每个测试用例的输出占一行,输出A+B的m进制数。 Sample Input8 1300 482 1 70 Sample Output25041000 A+B之后的值有可

2016-07-22 17:31:05 235

原创 hdu1062-字符串翻转问题 reverse()

1062Sample Input3olleh !dlrowm'I morf .udhI ekil .mca Sample Outputhello world!I'm from hdu.I like acm.HintRemember to use getchar() to read '\n' after the interger T,

2016-07-21 17:36:31 397

转载 快速幂算法

常规求幂[cpp] view plain copy int pow1(int a,int b)  {      int r=1;      while(b--)          r*=a;      return r;  }   二分求幂(一般)[cpp] view p

2016-07-21 10:51:11 330

原创 hdu1860-统计字符出现次数问题 string.find()

1860Sample Input I THIS IS A TEST i ng this is a long test string #Sample Output I 2 i 3 5 n 2 g 2 注:第2个测试用例中,空格也是被统计的字符之一。 string 类提供了 6 种查找函数,每种函数以不同形式的 find 命名。 这些操作全都返回 string::siz

2016-07-21 09:50:41 938

原创 hdu2035-求N^N的后三位

2035 Sample Input 2 3 12 6 6789 10000 0 0Sample Output 8 984 1可以AC,但是大数据会爆的代码↓#include <iostream> using namespace std; int main() { int m[6],a,b,n; while (cin>>a>>b && (a!=0 || b!=

2016-07-20 15:59:27 394

转载 C++STL之string详讲

在学习c++STL中的string,在这里做个笔记,以供自己以后翻阅和初学者参考。 1:string对象的定义和初始化以及读写 string s1; 默认构造函数,s1为空串 string s2(s1); 将s2初始化为s1的一个副本 string s3(“valuee”); 将s3初始化一个字符串面值副本 string s4(n,’c’); 将s4 初始化为字符’c

2016-07-19 16:23:32 381

原创 hdu1020-统计字符出现次数问题

Sample Input 2 ABC ABBCCCSample Output ABC A2B3C 1020 出错点1: 题目只对紧挨在一起的字符统计(相当于简写),并不是所有输入的字符。如 AABAAA 输出为 2AB3A 非 5AB 出错点2: for(i = 0;i#include <iostream> #include<string>using nam

2016-07-19 15:32:43 243

原创 hdu1061-N*N问题

1061 Problem Description Given a positive integer N, you should output the most right digit of N^N.Input The input contains several test cases. The first line of the input is a single integer T whic

2016-07-18 17:35:16 295 1

原创 hdu1108-最小公倍数最大公约数

杭电OJ1108最小公倍数 = 最大公约数 / 两数之积#include <iostream>using namespace std;int gcd(int a,int b){ while (a!=b) { if(a>b) a = a-b; else b = b-a; } return a;}int main(){ i

2016-07-17 15:00:38 343

原创 hdu1021-斐波拉契问题 找规律

杭电OJ1021这个要找规律,如果..硬算的话输入999999vc都停止辣 算出前面几个数发现是12022101八个数一轮回 0  1  2  3  4  5  6  7  8  9  10  11  12  13 1  2  0  2  2  1  0  1  1  2   0   2   2  1 no no yes no  no no yes  no  no  no

2016-07-17 11:45:13 361

原创 hdu1008-电梯问题

杭电OJ1008上楼:输入俩楼层之差 * 6s +停留层的5s 下楼:输入俩楼层之差 * 4s +停留层的5s#include <iostream> using namespace std; int main() { int n; while(cin>>n && n!=0) { int sum,i,str[100] = {0};

2016-07-17 10:45:26 401

原创 hdu1048-密码问题 字符串转换

杭电1048“`include includeusing namespace std; int main() { string str1,str; while(cin>>str1) { if(str1!=”ENDOFINPUT”) { cin>>str; cin>>str1; int

2016-07-16 16:37:11 305

空空如也

空空如也

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

TA关注的人

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