自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(41)
  • 资源 (1)
  • 收藏
  • 关注

原创 C++ 闹钟程序

#include<iostream> #include<string> #include<ctime> using namespace std;//时间类class Time{private: int hour; int minute; int second;public: //设置时间 void set(...

2019-03-12 14:37:41 1848 1

原创 unity连接mysql

unity连接mysql1.unity登录注册场景的创建2.mysql的建库建表3.unity与mysql的连接4.打包生成apk一.unity登录注册场景的创建1.创建panel2.创建用户输入框同样在panel目录下点击UI->inputfield 改名称为input name3.复制input name生成inputpassword生成如图:4.同样的方式创...

2018-11-06 19:44:42 1217 2

原创 HDU 1003 经典DP

Max SumTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 261877 Accepted Submission(s): 62235Problem DescriptionGiven a sequence

2017-11-19 14:08:25 331

转载 KMP

KMP算法是一种改进的字符串匹配算法,由D.E.Knuth,J.H.Morris和V.R.Pratt同时发现,因此人们称它为克努特——莫里斯——普拉特操作(简称KMP算法)。KMP算法的关键是利用匹配失败后的信息,尽量减少模式串与主串的匹配次数以达到快速匹配的目的。具体实现就是实现一个next()函数,函数本身包含了模式串的局部匹配信息。时间复杂度O(m+n)。举例来说,有一个字符串"

2017-09-10 17:02:40 337

原创 Pythagorean Triples

Katya studies in a fifth grade. Recently her class studied right triangles and the Pythagorean theorem. It appeared, that there are triples of positive integers such that you can construct a right tri

2017-08-24 09:57:01 375

原创 Multiplication Table (二分)

Bizon the Champion isn't just charming, he also is very smart.While some of us were learning the multiplication table, Bizon the Champion had fun in his own manner. Bizon the Champion painted an n

2017-08-24 09:40:33 488

转载 并查集详解之畅通工程

每每上网搜算法的时候都是带着沉重的心情去的,直到...遇到这篇文章(为了更多同病相怜的人...看来我得改变我的文字风格了) 真的笑死我了~好文章!原文章:http://blog.csdn.net/dellaserss/article/details/7724401/来看一个实例,杭电1232畅通工程首先在地图上给你若干个城镇,这些城镇都可以看作点,然后告诉你哪些

2017-08-22 16:42:24 330

原创 dijkstra算法 之 畅通工程续(图论)

先介绍一下dijkstra(迪杰斯特拉)算法:Dijkstra(迪杰斯特拉)算法是典型的单源最短路径算法,用于计算一个节点到其他所有节点的最短路径。主要特点是以起始点为中心向外层层扩展,直到扩展到终点为止。Dijkstra算法是很有代表性的最短路径算法,在很多专业课程中都作为基本内容有详细的介绍,如数据结构,图论,运筹学等等。注意该算法要求图中不存在负权边。(等会儿解释为什么存在负权边)

2017-08-22 15:03:02 315

原创 Fibonacci (矩阵快速幂)

In the Fibonacci integer sequence, F0 = 0, F1 = 1, and Fn = Fn − 1 + Fn − 2 for n ≥ 2. For example, the first ten terms of the Fibonacci sequence are:0, 1, 1, 2, 3, 5, 8, 13, 21, 34, …An alter

2017-08-14 20:10:06 478

原创 Blocks (矩阵快速幂)

Panda has received an assignment of painting a line of blocks. Since Panda is such an intelligent boy, he starts to think of a math problem of painting. Suppose there are N blocks in a line and each

2017-08-14 16:23:12 456

转载 【51Nod】1013 3的幂的和

文章出处:http://blog.csdn.net/jinbaosite/article/details/72676514?utm_source=itdadao&utm_medium=referral题意求:3^0 + 3^1 +…+ 3^(N) mod 1000000007解题思路由等比数列的前n相和,我们可以得到 3n+1−12%10

2017-08-13 21:01:23 255

原创 Open the Lock (BFS)

Now an emergent task for you is to open a password lock. The password is consisted of four digits. Each digit is numbered from 1 to 9.Each time, you can add or minus 1 to any digit. When add 1 to

2017-08-11 18:48:57 318

原创 Catch That Cow (BFS)

Farmer John has been informed of the location of a fugitive cow and wants to catch her immediately. He starts at a point N (0 ≤ N ≤ 100,000) on a number line and the cow is at a point K (0 ≤ K ≤ 100,0

2017-08-11 18:44:05 238

原创 Knight Moves (BFS)

Background Mr Somurolov, fabulous chess-gamer indeed, asserts that no one else but him can move knights from one position to another so fast. Can you beat him?The Problem Your task is to write

2017-08-11 17:08:14 347

原创 数塔 (dp)

在讲述DP算法的时候,一个经典的例子就是数塔问题,它是这样描述的:有如下所示的数塔,要求从顶层走到底层,若每一步只能走到相邻的结点,则经过的结点的数字之和最大是多少? 已经告诉你了,这是个DP的题目,你能AC吗?Input输入数据首先包括一个整数C,表示测试实例的个数,每个测试实例的第一行是一个整数N(1 <= N <= 100),表示数塔的高度,接下来用N行数字表示数

2017-08-11 16:44:22 510

原创 最长递增子序列 (dp)

给出长度为N的数组,找出这个数组的最长递增子序列。(递增子序列是指,子序列的元素是递增的)例如:5 1 6 8 2 4 5 10,最长递增子序列是1 2 4 5 10。Input第1行:1个数N,N为序列的长度(2 第2 - N + 1行:每行1个数,对应序列的元素(-10^9 Output输出最长递增子序列的长度。Sample Input85168

2017-08-11 16:19:26 551

原创 编辑距离 (dp)

编辑距离,又称Levenshtein距离(也叫做Edit Distance),是指两个字串之间,由一个转成另一个所需的最少编辑操作次数。许可的编辑操作包括将一个字符替换成另一个字符,插入一个字符,删除一个字符。例如将kitten一字转成sitting:sitten (k->s)sittin (e->i)sitting (->g)所以kitten和sitting的编辑距离是3。俄

2017-08-11 16:08:52 297

原创 最长公共子序列Lcs (dp)

给出两个字符串A B,求A与B的最长公共子序列(子序列不要求是连续的)。比如两个串为:abcicbaabdkscabab是两个串的子序列,abc也是,abca也是,其中abca是这两个字符串最长的子序列。Input第1行:字符串A 第2行:字符串B (A,B的长度 Output输出最长的子序列,如果有多个,随意输出1个。Sample Input

2017-08-11 16:03:50 309

原创 Common Subsequence (dp)

A subsequence of a given sequence is the given sequence with some elements (possible none) left out. Given a sequence X = another sequence Z = is a subsequence of X if there exists a strictly incr

2017-08-11 15:59:14 254

原创 循环数组最大子段和 (dp)

N个整数组成的循环序列a11,a22,a33,…,ann,求该序列如aii+ai+1i+1+…+ajj的连续的子段和的最大值(循环序列是指n个数围成一个圈,因此需要考虑an−1n−1,ann,a11,a22这样的序列)。当所给的整数均为负数时和为0。例如:-2,11,-4,13,-5,-2,和最大的子段为:11,-4,13。和为20。Input第1行:整数序列的长度N(2 第2 -

2017-08-11 15:35:15 426

原创 最大子段和 经典dp

N个整数组成的序列a11,a22,a33,…,ann, 求该序列如aii+ai+1i+1+…+ajj的连续子段和的最大值。当所给的整数均为负数时和为0。例如:-2,11,-4,13,-5,-2,和最大的子段为:11,-4,13。和为20。Input第1行:整数序列的长度N(2 第2 - N + 1行:N个整数(-10^9 Output输出最大子段和。Sample Inp

2017-08-10 21:50:53 529

原创 动态规划 经典DP

动态规划动态规划的基本思想将⼀个问题分解为⼦问题递归求解,且将中间结果保存以避免重复计算。通常⽤来求最优解,且最优解的局部也是最优的。求解过程产⽣多个决策序列,下⼀步总是依赖上⼀步的结果,⾃底向上的求解。 动态规划算法可分解成从先到后的4个步骤:1. 描述⼀个最优解的结构,寻找⼦问题,对问题进⾏划分。2. 定义状态。往往将和⼦问题相关的各个变量的⼀组取值定义为⼀个状态。某个...

2017-08-10 21:21:19 631

原创 Dividing (多重背包 动态规划)

Marsha and Bill own a collection of marbles. They want to split the collection among themselves so that both receive an equal share of the marbles. This would be easy if all the marbles had the same

2017-08-10 20:47:13 922

原创 悼念512汶川大地震遇难同胞——珍惜现在,感恩生活 (多重背包 动态规划)

急!灾区的食物依然短缺! 为了挽救灾区同胞的生命,心系灾区同胞的你准备自己采购一些粮食支援灾区,现在假设你一共有资金n元,而市场有m种大米,每种大米都是袋装产品,其价格不等,并且只能整袋购买。请问:你用有限的资金最多能采购多少公斤粮食呢? 后记: 人生是一个充满了变数的生命过程,天灾、人祸、病痛是我们生命历程中不可预知的威胁。 月有阴晴圆缺,人有旦夕祸福,未来对于我们而

2017-08-10 20:42:58 294

原创 Piggy-Bank (完全背包 动态规划)

Before ACM can do anything, a budget must be prepared and the necessary financial support obtained. The main income for this action comes from Irreversibly Bound Money (IBM). The idea behind is simple

2017-08-09 22:46:32 266

原创 饭卡 (背包问题 动态规划)

电子科大本部食堂的饭卡有一种很诡异的设计,即在购买之前判断余额。如果购买一个商品之前,卡上的剩余金额大于或等于5元,就一定可以购买成功(即使购买后卡上余额为负),否则无法购买(即使金额足够)。所以大家都希望尽量使卡上的余额最少。某天,食堂中有n种菜出售,每种菜可购买一次。已知每种菜的价格以及卡上的余额,问最少可使卡上的余额为多少。Input多组数据。对于每组数据:第一行为正整数n,表...

2017-08-09 22:30:14 435

原创 Bone Collector (01背包)

Many years ago , in Teddy’s hometown there was a man who was called “Bone Collector”. This man like to collect varies of bones , such as dog’s , cow’s , also he went to the grave …The bone collect

2017-08-09 22:14:14 344

原创 Untitled ( DFS 递归 )

There is an integer a and n integers b1,…,bn. After selecting some numbers from b1,…,bn in any order, say c1,…,cr, we want to make sure that a mod c1 mod c2 mod… mod cr=0 (i.e., a will become the rema

2017-08-04 09:23:00 291

原创 全排列(DFS递归+STL set)

给出一个字符串S(可能有重复的字符),按照字典序从小到大,输出S包括的字符组成的所有排列。例如:S = "1312",输出为:112311321213123113121321211321312311311231213211Input输入一个字符串S(S的长度 Output输出S所包含的字符组成的所有排列Sample Inp

2017-08-03 18:35:46 394

原创 Prime Ring Problem(DFS)

A ring is compose of n circles as shown in diagram. Put natural number 1, 2, ..., n into each circle separately, and the sum of numbers in two adjacent circles should be a prime.Note: the number

2017-08-03 15:12:21 205

原创 Oil Deposits (DFS)

The GeoSurvComp geologic survey company is responsible for detecting underground oil deposits. GeoSurvComp works with one large rectangular region of land at a time, and creates a grid that divides th

2017-08-03 14:42:26 290

原创 迷宫问题 ( BFS )

定义一个二维数组: int maze[5][5] = {0, 1, 0, 0, 0,0, 1, 0, 1, 0,0, 0, 0, 0, 0,0, 1, 1, 1, 0,0, 0, 0, 1, 0,};它表示一个迷宫,其中的1表示墙壁,0表示可以走的路,只能横着走或竖着走,不能斜着走,要求编程序找出从左上角到右下角的最短路线。Inp

2017-08-03 14:09:28 1228

原创 Lake Counting (DFS )

Due to recent rains, water has pooled in various places in Farmer John's field, which is represented by a rectangle of N x M (1 <= N <= 100; 1 <= M <= 100) squares. Each square contains either water

2017-08-01 22:24:54 230

原创 The kth great number(优先队列)

The kth great number Xiao Ming and Xiao Bao are playing a simple Numbers game. In a round Xiao Ming can choose to write down a number, or ask Xiao Bao what the kth great number is. Because the n

2017-07-30 14:27:52 373

原创 Misha and Changing Handles(字符串修改)

**Misha and Changing Handles** Misha hacked the Codeforces site. Then he decided to let all the users change their handles. A user can now change his handle any number of times. But each new handle mu

2017-07-30 14:24:59 468

原创 ACM 格式化输出,杨辉三角

格式化输出还记得中学时候学过的杨辉三角吗?具体的定义这里不再描述,你可以参考以下的图形:1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 1 5 10 10 5 1 Input输入数据包含多个测试实例,每个测试实例的输入只包含一个正整数n(1Output对应于每一个输入,请输出相应层数的杨辉三角,每一层的整数之间用一个空格隔开,每一个杨辉三

2017-07-30 12:04:04 695

原创 STL 成员函数

stack:先进后出 FILO{   构造析构:   stack c     创建一个空的stack   stack c2(c)    复制stack   数据增减:   c.top()       返回栈顶数据   c.push(x)     在栈顶增加elem数据   c.pop()       弹出栈顶数据   其他操作:   c.empty()

2017-07-26 22:53:32 416

原创 归并排序-递归

#include#define num 10int a[num];void Merging(int a[],int first,int mid,int end){ int i=first,m=mid; int j=mid+1,n=end; int k=0; int temp[num]; while(i<=m&&j<=n) {

2017-05-05 23:26:59 321

原创 字符串过滤

输入一个字符串str1,把其中的连续非数字的字符子串换成一个‘*’,存入字符数组str2 中,所有数字字符也必须依次存入 str2 中。输出str2。  【样例输入】: $Ts!47&*s456  a23* +B9k  【样例输出】: *47*456*23*9*#include#includeint main(){ char str1[50],str2[50

2017-05-01 20:07:00 1115

原创 字符串删除

删除一个字符串中的某段字符串 如abcd123eg456删除cd后成为ab123eg456#includeint main(){ char a[100],b[100]; int i,j; printf("请输入主串:"); gets(a); printf("请输入子串:"); gets(b); for(i=0; a[i]!=0; i+

2017-05-01 15:54:42 378

python小练习

比较简单有趣的python小练习,适合初学者使用,不过我觉得只列出三两个是远远不够的,因此就收集并这个项目列表,大家要找简单的编程项目学习练手的话,可以收藏并扩散本文。这些项目并不是论文级别的,只是想抛砖引玉让大家能从中受些启发。

2018-07-25

空空如也

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

TA关注的人

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