Acm
文章平均质量分 86
lishuhuakai
这个作者很懒,什么都没留下…
展开
-
杭电OJ——1232 畅通工程(并查集)
畅通工程Problem Description某省调查城镇交通状况,得到现有城镇道路统计表,表中列出了每条道路直接连通的城镇。省政府“畅通工程”的目标是使全省任何两个城镇间都可以实现交通(但不一定有直接的道路相连,只要互相间接通过道路可达即可)。问最少还需要建设多少条道路?Input测试输入包含若干测试用例。每个测试用例的第1行给出两个正整数原创 2013-01-21 15:15:49 · 14079 阅读 · 4 评论 -
杭电OJ——1011 Starship Troopers(dfs + 树形dp)
Starship TroopersProblem DescriptionYou, the leader of Starship Troopers, are sent to destroy a base of the bugs. The base is built underground. It is actually a huge cavern, which consists原创 2013-06-27 23:26:36 · 4890 阅读 · 1 评论 -
杭电OJ—— 1014 Uniform Generator
Uniform GeneratorProblem DescriptionComputer simulations often require random numbers. One way to generate pseudo-random numbers is via a function of the formseed(x+1) = [seed(x) + STEP]原创 2013-07-05 17:48:48 · 3232 阅读 · 0 评论 -
杭电OJ—— 1017 A Mathematical Curiosity
A Mathematical CuriosityProblem DescriptionGiven two integers n and m, count the number of pairs of integers (a,b) such that 0 This problem contains multiple test cases!The first lin原创 2013-07-05 18:45:01 · 2562 阅读 · 2 评论 -
杭电OJ—— 1084 What Is Your Grade?
What Is Your Grade?Problem Description“Point, point, life of student!”This is a ballad(歌谣)well known in colleges, and you must care about your score in this exam too. How many points can y原创 2013-07-28 15:41:06 · 3157 阅读 · 0 评论 -
杭电DIY——金币游戏
金币游戏Problem Description海盗鲍里斯和瓦西里正在玩一个非常有趣的游戏。他们两人共有n个装有金币的箱子,箱子被从1到n进行了编号,第i号箱子中有a[i]枚金币。在游戏中鲍里斯和瓦西里轮流进行游戏操作,鲍里斯首先进行操作。在每一轮游戏中选手可以选择一个整数x(2x+1鲍里斯不是一个贪婪的守财奴,但鲍里斯是一个懒惰的家伙。因此,他想知道最少几轮游戏操作原创 2013-09-23 10:23:43 · 1687 阅读 · 0 评论 -
杭电OJ——1007 Quoit Design(最近点对问题)
Quoit DesignProblem DescriptionHave you ever played quoit in a playground? Quoit is a game in which flat rings are pitched at some toys, with all the toys encircled awarded.In the field of原创 2013-06-24 14:03:15 · 16426 阅读 · 5 评论 -
杭电OJ——1051 Wooden Sticks
Wooden SticksProblem DescriptionThere is a pile of n wooden sticks. The length and weight of each stick are known in advance. The sticks are to be processed by a woodworking machine in o原创 2012-10-26 22:52:00 · 8105 阅读 · 2 评论 -
杭电OJ——1039 Easier Done Than Said?(水题)
Easier Done Than Said?Problem DescriptionPassword security is a tricky thing. Users prefer simple passwords that are easy to remember (like buddy), but such passwords are often insecure. Som原创 2013-07-08 20:35:10 · 2236 阅读 · 0 评论 -
杭电OJ——2003 求绝对值
求绝对值Problem Description求实数的绝对值。 Input输入数据有多组,每组占一行,每行包含一个实数。 Output对于每组输入数据,输出它的绝对值,要求每组数据输出一行,结果保留两位小数。 Sample Input123-234.00 Sample原创 2013-01-22 14:33:28 · 5918 阅读 · 1 评论 -
杭电OJ——2046 骨牌铺方格(简单的推断题)
骨牌铺方格Problem Description在2×n的一个长方形方格中,用一个1× 2的骨牌铺满方格,输入n ,输出铺放方案的总数.例如n=3时,为2× 3方格,骨牌的铺放方案有三种,如下图: Input输入数据由多行组成,每行包含一个整数n,表示该测试实例的长方形方格的规格是2×n (0 Output对于原创 2013-01-22 19:34:55 · 22826 阅读 · 3 评论 -
杭电OJ——1272 小希的迷宫
小希的迷宫Problem Description上次Gardon的迷宫城堡小希玩了很久(见Problem B),现在她也想设计一个迷宫让Gardon来走。但是她设计迷宫的思路不一样,首先她认为所有的通道都应该是双向连通的,就是说如果有一个通道连通了房间A和B,那么既可以通过它从房间A走到房间B,也可以通过它从房间B走到房间A,为了提高难度,小希希望任意两个房间有且仅有一条路径可原创 2013-01-21 16:59:40 · 8674 阅读 · 2 评论 -
杭电OJ——1198 Farm Irrigation (并查集)
Farm IrrigationProblem DescriptionBenny has a spacious farm land to irrigate. The farm land is a rectangle, and is divided into a lot of samll squares. Water pipes are placed in these square原创 2013-01-21 21:24:25 · 1716 阅读 · 0 评论 -
杭电OJ——1030 Delta-wave
Delta-waveProblem DescriptionA triangle field is numbered with successive integers in the way shown on the picture below. The traveller needs to go from the cell with number M to t原创 2013-07-06 19:21:06 · 2209 阅读 · 0 评论 -
杭电OJ——1032 The 3n + 1 problem
The 3n + 1 problemProblem DescriptionProblems in Computer Science are often classified as belonging to a certain class of problems (e.g., NP, Unsolvable, Recursive). In this problem you will b原创 2013-07-06 21:12:10 · 2971 阅读 · 0 评论 -
杭电OJ——1038 Biker's Trip Odometer
Biker's Trip OdometerProblem DescriptionMost bicycle speedometers work by using a Hall Effect sensor fastened to the front fork of the bicycle. A magnet is attached to one of the spokes on the原创 2013-07-07 15:39:49 · 2399 阅读 · 0 评论 -
杭电OJ——1033 Edge
EdgeProblem DescriptionFor products that are wrapped in small packings it is necessary that the sheet of paper containing the directions for use is folded until its size becomes small enough原创 2013-07-07 14:43:05 · 2945 阅读 · 0 评论 -
杭电OJ——1041 Computer Transformation
Computer TransformationProblem DescriptionA sequence consisting of one digit, the number 1 is initially written into a computer. At each successive time step, the computer simultaneously tra原创 2013-07-08 23:06:03 · 3251 阅读 · 0 评论 -
杭电OJ——1016 Prime Ring Problem
Prime Ring ProblemProblem DescriptionA 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 adjace原创 2012-09-24 22:56:25 · 7372 阅读 · 2 评论 -
杭电OJ--2099 整除的尾数
现在又开始刷题了,要开始准备ccf的考试了,每天来刷一道题练练手!话说真的好久都没有碰过ACM的题目了,很多东西都已经生疏了,看来还是得补补!这道题目纯粹的水题,只是要注意输出的格式,需要注意输出的数字应该占两位,即用%02d来控制输出的宽度。Problem Description一个整数,只知道前几位,不知道末二位,被另一个整数除尽了,那么该数的末二位该是什么原创 2015-09-10 07:20:35 · 1516 阅读 · 0 评论 -
杭电OJ--2098 分拆素数和
Problem Description把一个偶数拆成两个不同素数的和,有几种拆法呢? Input输入包含一些正的偶数,其值不会超过10000,个数不会超过500,若遇0,则结束。 Output对应每个偶数,输出其拆成不同素数的个数,每个结果占一行。 Sample Input30260原创 2015-09-10 08:30:03 · 2061 阅读 · 0 评论 -
杭电OJ——1212 Big Number
Big NumberProblem DescriptionAs we know, Big Number is always troublesome. But it's really important in our ACM. And today, your task is to write a program to calculate A mod B.To make the原创 2013-01-18 15:20:01 · 2516 阅读 · 0 评论 -
杭电OJ——1172 猜数字(水题)
猜数字Problem Description猜数字游戏是gameboy最喜欢的游戏之一。游戏的规则是这样的:计算机随机产生一个四位数,然后玩家猜这个四位数是什么。每猜一个数,计算机都会告诉玩家猜对几个数字,其中有几个数字在正确的位置上。比如计算机随机产生的数字为1122。如果玩家猜1234,因为1,2这两个数字同时存在于这两个数中,而且1在这两个数中的位置是相同的,所以计算原创 2012-12-15 00:45:01 · 4058 阅读 · 2 评论 -
杭电OJ ——1009——FatMouse' Trade
FatMouse' Trade Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Problem DescriptionFatMouse prepared M p原创 2012-09-20 01:16:34 · 2808 阅读 · 0 评论 -
杭电OJ——1006 Tick and Tick
Tick and Tick Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Problem DescriptionThe thre原创 2012-09-19 22:50:05 · 2353 阅读 · 0 评论 -
杭电OJ——Tempter of the Bone
Tempter of the Bone Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Problem DescriptionThe doggie found a bone in an ancient m原创 2012-09-21 00:33:17 · 1308 阅读 · 1 评论 -
leetcode -- Unique Binary Search Trees
题目描述给定一个n,我们可以构建多少棵二叉搜索树呢?使用值1~n填充树的节点.举个例子,如果n=3,那么一共会存在5棵这样的树: 1 3 3 2 1 \ / / / \ \ 3 2 1 1 3 2 / / \原创 2017-06-17 23:00:25 · 406 阅读 · 0 评论 -
leetcode -- Word Break
题目描述给定一个非空的字符串s以及一个包含了很多非空词语的字典,判断s是否能够拆解为一个以及多个词典词语,你可以假定,字典中不会包含重复的词语.下面是一个例子:s = "leetcode",dict = ["leet", "code"]这个例子应该返回true,因为leetcode可以被拆解成为leet code.题目扩展给定一个非空的字符串s和一个包含了很多非空词语的字典,在s中添加空格来构建一原创 2017-06-19 00:37:08 · 570 阅读 · 0 评论 -
leetcode -- Combination Sum
这是一套非常有意思的套题,我想在这里总结一下个人的心得.一. Combination Sum给定一组没有重复的,候选的数字 C ,以及一个目标数字 T ,找到在 C 中所有的组合,使得该组合的和为 T.在 C 中的每一个数字可以重复无数多次.注意:所有的数字,包括 T, 都为正数.最终输出的方案中不应该包含重复的组合.举个栗子,给定 C 为 [2, 3, 6, 7] , 以及 T 7.可以得到原创 2017-06-23 00:42:59 · 615 阅读 · 0 评论 -
leetcode -- Single number
Single number I给定一个整数数组, 数组中的每个数都出现了 2 次,除了一个数, 它只出现了 1 次,请将它找出来.思路位操作 ^ 有着非常漂亮的性质,首先,它支持交换律:A ^ B = B ^ A其次,它还支持结合率:A ^ B ^ C = A ^ (B ^ C) = (A ^ B) ^ C然后, ^ 本身具有这样的语义:A ^ A = 0, A ^ 0 = A我们可以很清楚地知道:翻译 2017-08-05 02:53:06 · 474 阅读 · 0 评论 -
关于next_permutation函数的模拟!
现在有一道很简单的题目,那就是输出1——n的所有排列数!比如说,输入n=5;那么要求求出1,2,3,4,5这几个数所有的排列数!c++中有一个next_permutation函数,它包含在algorithm头文件中,可以方便的求出所有的排列数,可是你知道它是怎么实现的么?现在,我对那个函数进行了简单的模拟,模拟函数如下:/************原创 2012-09-22 11:46:02 · 1878 阅读 · 1 评论 -
杭电OJ -- 2041 超级楼梯
原本以为这道题目涉及到了动态规划,可是没有,仔细分析了一下,这道题目更加像是一道思考题.想通了,非常easy,否则就是一个坑.原创 2015-10-11 00:04:58 · 4518 阅读 · 0 评论 -
杭电OJ--2097 Sky数
Problem DescriptionSky从小喜欢奇特的东西,而且天生对数字特别敏感,一次偶然的机会,他发现了一个有趣的四位数2992,这个数,它的十进制数表示,其四位数字之和为2+9+9+2=22,它的十六进制数BB0,其四位数字之和也为22,同时它的十二进制数表示1894,其四位数字之和也为22,啊哈,真是巧啊。Sky非常喜欢这种四位数,由于他的发现,所以这里我们命名其为Sky数。但原创 2015-09-11 08:25:40 · 1095 阅读 · 0 评论 -
杭电OJ -- 2091 空心三角形
Problem Description把一个字符三角形掏空,就能节省材料成本,减轻重量,但关键是为了追求另一种视觉效果。在设计的过程中,需要给出各种花纹的材料和大小尺寸的三角形样板,通过电脑临时做出来,以便看看效果。 Input每行包含一个字符和一个整数n(0 Output每个样板三角形之间应空上一行,三角形的中间为空。显然行原创 2015-09-25 22:53:40 · 1163 阅读 · 0 评论 -
杭电OJ--2096 小明A+B
Problem Description小明今年3岁了, 现在他已经能够认识100以内的非负整数, 并且能够进行100以内的非负整数的加法计算.对于大于等于100的整数, 小明仅保留该数的最后两位进行计算, 如果计算结果大于等于100, 那么小明也仅保留计算结果的最后两位.例如, 对于小明来说:1) 1234和34是相等的2) 35+80=15给定非负整数A和B,原创 2015-09-12 07:43:43 · 1064 阅读 · 0 评论 -
杭电OJ -- 2084 数塔(动态规划)
Problem Description在讲述DP算法的时候,一个经典的例子就是数塔问题,它是这样描述的:有如下所示的数塔,要求从顶层走到底层,若每一步只能走到相邻的结点,则经过的结点的数字之和最大是多少?已经告诉你了,这是个DP的题目,你能AC吗? Input输入数据首先包括一个整数C,表示测试实例的个数,每个测试实例的第一行是一个整数N(1原创 2015-09-28 09:06:33 · 1426 阅读 · 0 评论 -
杭电OJ-- 2095 find your present (依然很水)
Problem DescriptionIn the new year party, everybody will get a "special present".Now it's your turn to get your special present, a lot of presents now putting on the desk, and only one of them wil原创 2015-09-13 16:57:58 · 1719 阅读 · 0 评论 -
杭电OJ -- 2034 人见人爱A-B(c++练手的好题目)
人见人爱A-BProblem Description参加过上个月月赛的同学一定还记得其中的一个最简单的题目,就是{A}+{B},那个题目求的是两个集合的并集,今天我们这个A-B求的是两个集合的差,就是做集合的减法运算。(当然,大家都知道集合的定义,就是同一个集合中不会有两个相同的元素,这里还是提醒大家一下)呵呵,很简单吧? Input每组输入数据原创 2015-10-04 11:39:00 · 3699 阅读 · 0 评论 -
杭电OJ -- 2033 人见人爱A+B(c++练手的好题目)
人见人爱A+BProblem DescriptionHDOJ上面已经有10来道A+B的题目了,相信这些题目曾经是大家的最爱,希望今天的这个A+B能给大家带来好运,也希望这个题目能唤起大家对ACM曾经的热爱。这个题目的A和B不是简单的整数,而是两个时间,A和B 都是由3个整数组成,分别表示时分秒,比如,假设A为34 45 56,就表示A所表示的时间是34小时 45分钟 56秒原创 2015-10-04 09:33:20 · 2232 阅读 · 0 评论 -
杭电OJ-- 2094 产生冠军
Problem Description有一群人,打乒乓球比赛,两两捉对撕杀,每两个人之间最多打一场比赛。球赛的规则如下:如果A打败了B,B又打败了C,而A与C之间没有进行过比赛,那么就认定,A一定能打败C。如果A打败了B,B又打败了C,而且,C又打败了A,那么A、B、C三者都不可能成为冠军。根据这个规则,无需循环较量,或许就能确定冠军。你的任务就是面对一群比赛选手,在经过了原创 2015-09-19 23:32:13 · 2181 阅读 · 0 评论