自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

转载 已知前序(先序)与中序输出后序

转自: http://www.liuchuo.net/archives/2087已知前序(先序)与中序输出后序: 前序:1, 2, 3, 4, 5, 6(根左右) 中序:3, 2, 4, 1, 6, 5(左根右) 分析:因为前序(根左右)最先出现的总是根结点,所以令root为前序中当前的根结点下标(并且同时把一棵树分为左子树和右子树)。start为当前需要打印的子树在中序中的最左边的下标,en

2017-02-19 23:50:16 420

转载 已知后序与中序输出前序(先序)

转自:http://www.liuchuo.net/archives/2090已知后序与中序输出前序(先序)已知后序与中序输出前序(先序): 后序:3, 4, 2, 6, 5, 1(左右根) 中序:3, 2, 4, 1, 6, 5(左根右) 分析:因为后序的最后一个总是根结点,令i在中序中找到该根结点,则i把中序分为两部分,左边是左子树,右边是右子树。因为是输出先序(根左右),所以先打印出当前

2017-02-19 23:49:11 619

原创 codeforces 735D Taxes 哥德巴赫猜想

哥德巴赫猜想,一个偶数可以是两个质数之和,那么一个奇数x有三种情况: 1.x本身是质数 2.(x-2)是质数,那么可以拆成两个质数 3.拆成一个质数和一个偶数,即三个质数#include<bits/stdc++.h>using namespace std;bool isprime(int n) { if(n < 2)return false; for(int i = 2;

2017-02-15 11:17:09 331

原创 codeforces 397div2 D Artsem and Saunders

D. Artsem and Saunders time limit per test 2 seconds memory limit per test 512 megabytes input standard input output standard output Artsem has a friend Saunders from University of Chicago. Sa

2017-02-15 01:08:27 297

原创 codeforces 397div2 D Artsem and Saunders

D. Artsem and Saunders time limit per test 2 seconds memory limit per test 512 megabytes input standard input output standard output Artsem has a friend Saunders from University of Chicago. Sa

2017-02-15 01:02:27 263

原创 codeforces 397div2 D Artsem and Saunders

D. Artsem and Saunders time limit per test 2 seconds memory limit per test 512 megabytes input standard input output standard output Artsem has a friend Saunders from University of Chicago. Sa

2017-02-15 01:00:25 262

原创 codeforces 397div2 D Artsem and Saunders

D. Artsem and Saunders time limit per test 2 seconds memory limit per test 512 megabytes input standard input output standard output Artsem has a friend Saunders from University of Chicago. Sa

2017-02-15 01:00:24 431

原创 poj 3666 Making the Grade

A straight dirt road connects two fields on FJ’s farm, but it changes elevation more than FJ would like. His cows do not mind climbing up or down a single slope, but they are not fond of an alternating

2017-02-13 02:52:40 328

原创 蓝桥 2的次幂表示

问题描述   任何一个正整数都可以用2进制表示,例如:137的2进制表示为10001001。   将这种2进制表示写成2的次幂的和的形式,令次幂高的排在前面,可得到如下表达式:137=2^7+2^3+2^0   现在约定幂次用括号来表示,即a^b表示为a(b)   此时,137可表示为:2(7)+2(3)+2(0)   进一步:7=2^2+2+2^0 (2^1用2表示)   3=2+2^

2017-02-12 00:53:23 313

原创 蓝桥 金钗十三陵

问题描述   在电影《金陵十三钗》中有十二个秦淮河的女人要自我牺牲代替十二个女学生去赴日本人的死亡宴会。为了不让日本人发现,自然需要一番乔装打扮。但由于天生材质的原因,每个人和每个人之间的相似度是不同的。由于我们这是编程题,因此情况就变成了金陵n钗。给出n个女人和n个学生的相似度矩阵,求她们之间的匹配所能获得的最大相似度。   所谓相似度矩阵是一个n*n的二维数组like[i][j]。其中i,j

2017-02-12 00:50:40 2518

原创 蓝桥 最大子矩阵

问题描述   给定一个n*m的矩阵A,求A中的一个非空子矩阵,使这个子矩阵中的元素和最大。  其中,A的子矩阵指在A中行和列均连续的一块。 输入格式   输入的第一行包含两个整数n, m,分别表示矩阵A的行数和列数。   接下来n行,每行m个整数,表示矩阵A。 输出格式   输出一行,包含一个整数,表示A中最大的子矩阵中的元素和。 样例输入 3 3 -1 -4 3 3 4 -1

2017-02-11 23:47:03 440

原创 蓝桥 大臣的旅费

问题描述很久以前,T王国空前繁荣。为了更好地管理国家,王国修建了大量的快速路,用于连接首都和王国内的各大城市。为节省经费,T国的大臣们经过思考,制定了一套优秀的修建方案,使得任何一个大城市都能从首都直接或者通过其他大城市间接到达。同时,如果不重复经过大城市,从首都到达每个大城市的方案都是唯一的。J是T国重要大臣,他巡查于各大城市之间,体察民情。所以,从一个城市马不停蹄地到另一个城市成了J最常做的事情

2017-02-11 23:36:41 368

原创 Mahmoud and a Dictionary codeforces396 div2 D

D. Mahmoud and a Dictionary time limit per test4 seconds memory limit per test256 megabytes inputstandard input outputstandard output Mahmoud wants to write a new dictionary that contains n words

2017-02-08 18:30:22 492

原创 C. Mahmoud and a Message 396 div2 C dp好题

Mahmoud wrote a message s of length n. He wants to send it as a birthday present to his friend Moaz who likes strings. He wrote it on a magical paper but he was surprised because some characters disapp

2017-02-08 14:52:34 487

转载 uva 11463 Commandos

A group of commandos were assigned a critical task. They are to destroy an enemy head quarter. The enemy head quarter consists of several buildings and the buildings are connected by roads. The command

2017-02-07 01:01:07 338

原创 poj 2367 拓扑排序

The system of Martians’ blood relations is confusing enough. Actually, Martians bud when they want and where they want. They gather together in different groups, so that a Martian can have one parent a

2017-02-07 00:55:55 343

原创 hdu 1875 继续畅通工程

相信大家都听说一个“百岛湖”的地方吧,百岛湖的居民生活在不同的小岛中,当他们想去其他的小岛时都要通过划小船来实现。现在政府决定大力发展百岛湖,发展首先要解决的问题当然是交通问题,政府决定实现百岛湖的全畅通!经过考察小组RPRush对百岛湖的情况充分了解后,决定在符合条件的小岛间建上桥,所谓符合条件,就是2个小岛之间的距离不能小于10米,也不能大于1000米。当然,为了节省资金,只要求实现任意2个小岛

2017-02-07 00:53:31 308

原创 hdu 1869 最短路裸题

1967年,美国著名的社会学家斯坦利・米尔格兰姆提出了一个名为“小世界现象(small world phenomenon)”的著名假说,大意是说,任何2个素不相识的人中间最多只隔着6个人,即只用6个人就可以将他们联系在一起,因此他的理论也被称为“六度分离”理论(six degrees of separation)。虽然米尔格兰姆的理论屡屡应验,一直也有很多社会学家对其兴趣浓厚,但是在30多年的时间里

2017-02-07 00:14:57 371

原创 hdu 1078 记忆化搜索

FatMouse has stored some cheese in a city. The city can be considered as a square grid of dimension n: each grid location is labelled (p,q) where 0 <= p < n and 0 <= q < n. At each grid location Fatmou

2017-02-06 17:01:34 503

原创 poj 3186

FJ has purchased N (1 <= N <= 2000) yummy treats for the cows who get money for giving vast amounts of milk. FJ sells one treat per day and wants to maximize the money he receives over a given period t

2017-02-06 16:58:27 307

原创 poj 2533 最大上升子序列

A numeric sequence of ai is ordered if a1 < a2 < … < aN. Let the subsequence of the given numeric sequence ( a1, a2, …, aN) be any sequence ( ai1, ai2, …, aiK), where 1 <= i1 < i2 < … < iK <= N. For ex

2017-02-06 16:27:21 473

原创 poj 1661

“Help Jimmy” 是在下图所示的场景上完成的游戏。 场景中包括多个长度和高度各不相同的平台。地面是最低的平台,高度为零,长度无限。 Jimmy老鼠在时刻0从高于所有平台的某处开始下落,它的下落速度始终为1米/秒。当Jimmy落到某个平台上时,游戏者选择让它向左还是向右跑,它跑动的速度也是1米/秒。当Jimmy跑到平台的边缘时,开始继续下落。Jimmy每次下落的高度不能超过MAX米,不然就会摔

2017-02-06 16:23:46 289

原创 poj 1458 最长公共子序列

A subsequence of a given sequence is the given sequence with some elements (possible none) left out. Given a sequence X = < x1, x2, …, xm > another sequence Z = < z1, z2, …, zk > is a subsequence of X

2017-02-06 15:36:24 595

原创 hdu 1160 FatMouse's Speed

FatMouse believes that the fatter a mouse is, the faster it runs. To disprove this, you want to take the data on a collection of mice and put as large a subset of this data as possible into a sequence

2017-02-06 13:23:29 294

原创 hdu 1257 最少拦截系统

某国为了防御敌国的导弹袭击,发展出一种导弹拦截系统.但是这种导弹拦截系统有一个缺陷:虽然它的第一发炮弹能够到达任意的高度,但是以后每一发炮弹都不能超过前一发的高度.某天,雷达捕捉到敌国的导弹来袭.由于该系统还在试用阶段,所以只有一套系统,因此有可能不能拦截所有的导弹. 怎么办呢?多搞几套系统呗!你说说倒蛮容易,成本呢?成本是个大问题啊.所以俺就到这里来求救了,请帮助计算一下最少需要多少套拦截系统

2017-02-06 12:37:44 549

原创 Tickets HDU - 1260

知道一个人买票花的时间和和前面那个人一起买票花的时间,问最少花多少时间可以把票卖完.. dp[1]=s[i] for i 2~n dp[i]=min(dp[i-1]+s[i],dp[i-2]+d[i]);#include <cstdio>#include <cstring>#include <string>#include <iostream>#include <algorithm>u

2017-02-06 12:33:02 282

原创 hdu 1176 免费馅饼

都说天上不会掉馅饼,但有一天gameboy正走在回家的小径上,忽然天上掉下大把大把的馅饼。说来gameboy的人品实在是太好了,这馅饼别处都不掉,就掉落在他身旁的10米范围内。馅饼如果掉在了地上当然就不能吃了,所以gameboy马上卸下身上的背包去接。但由于小径两侧都不能站人,所以他只能在小径上接。由于gameboy平时老呆在房间里玩游戏,虽然在游戏中是个身手敏捷的高手,但在现实中运动神经特别迟钝,

2017-02-06 12:29:41 510

原创 hdu 1114 Piggy-Bank (完全背包)

题意:存钱罐可以往里面放一些价值小的钱,但是时间久了就不知道里面有多少钱了,除非你打破它。现在给出空罐子的重量和最满能装到多重,然后给出每种硬币的价值和重量,我们要在不打破它的情况下确认罐子里最少有多少钱。 for i 1~n; for j w[i]~weight; dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]); 由于 http://blog.

2017-02-06 12:14:01 794

原创 hdu 1087 Super Jumping! Jumping! Jumping!

Nowadays, a kind of chess game called “Super Jumping! Jumping! Jumping!” is very popular in HDU. Maybe you are a good boy, and know little about this game, so I introduce it to you now. The game can be

2017-02-06 11:44:44 557

原创 hdu 1069(最长上升子序列变形)

A group of researchers are designing an experiment to test the IQ of a monkey. They will hang a banana at the roof of a building, and at the mean time, provide the monkey with some blocks. If the monke

2017-02-05 23:55:41 487

原创 蓝桥 生命之树

原题:在X森林里,上帝创建了生命之树。他给每棵树的每个节点(叶子也称为一个节点)上,都标了一个整数,代表这个点的和谐值。 上帝要在这棵树内选出一个非空节点集S,使得对于S中的任意两个点a,b,都存在一个点列 {a, v1, v2, …, vk, b} 使得这个点列中的每个点都是S里面的元素,且序列中相邻两个点间有一条边相连。 在这个前提下,上帝要使得S中的点所对应的整数的和尽量大。 这个最大的

2017-02-04 17:04:39 346

原创 C. Timofey and a tree codeforces 395 div2 C

Each New Year Timofey and his friends cut down a tree of n vertices and bring it home. After that they paint all the n its vertices, so that the i-th vertex gets color ci.Now it’s time for Timofey birt

2017-02-03 11:30:00 484

空空如也

空空如也

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

TA关注的人

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