
OJ
Veropatrinica
这个作者很懒,什么都没留下…
展开
-
NOI 3255:十进制到六进制
描述进制转换: 将十进制(不超过int类型表示的范围)的数转换为六进制的数.输入输入为第一行是组数n,后面n行是需要进制转换的十进制数.输出进制转换后的n行六进制数。样例输入31346265样例输出211141121#include<cstring>#include<iostream>#include<cma...原创 2018-07-17 11:03:13 · 827 阅读 · 0 评论 -
POJ 3253 Fence Repair(贪心)
DescriptionFarmer John wants to repair a small length of the fence around the pasture. He measures the fence and finds that he needs N (1 ≤ N ≤ 20,000) planks of wood, each having some integer lengt...原创 2018-07-09 10:42:00 · 164 阅读 · 0 评论 -
POJ 2387 Til the Cows Come Home (Dijkstra)
DescriptionBessie is out in the field and wants to get back to the barn to get as much sleep as possible before Farmer John wakes her for the morning milking. Bessie needs her beauty sleep, so she w...原创 2018-07-08 21:35:24 · 141 阅读 · 0 评论 -
POJ 3069 Saruman's Army
DescriptionSaruman the White must lead his army along a straight path from Isengard to Helm’s Deep. To keep track of his forces, Saruman distributes seeing stones, known as palantirs, among the troo...原创 2018-07-08 19:38:32 · 172 阅读 · 0 评论 -
POJ 3617 Best Cow Line(贪心)
DescriptionFJ is about to take his N (1 ≤ N ≤ 2,000) cows to the annual"Farmer of the Year" competition. In this contest every farmer arranges his cows in a line and herds them past the judges....原创 2018-07-08 15:29:31 · 279 阅读 · 0 评论 -
百炼3247 回文素数(递归)
描述一个数如果从左往右读和从右往左读数字是相同的,则称这个数是回文数,如121,1221,15651都是回文数。给定位数n,找出所有既是回文数又是素数的n位十进制数。(注:不考虑超过整型数范围的情况)。输入位数n,其中1<=n<=9。输出第一行输出满足条件的素数个数。第二行按照从小到大的顺序输出所有满足条件的素数,两个数之间用一个空格区分。样例输入1样例输出42 3...原创 2018-07-08 11:12:24 · 654 阅读 · 0 评论 -
POJ 1458 Common Subsequence
DescriptionA 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, ..., ...原创 2018-04-17 23:42:47 · 280 阅读 · 0 评论 -
POJ - 2386 Lake Counting(DFS)
Description 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 sq...原创 2018-04-11 22:52:31 · 161 阅读 · 0 评论 -
Aizu - 0558 Cheese(BFS)
问题描述 在H * W的地图上有N个奶酪工厂,每个工厂分别生产硬度为1-N的奶酪。有一只老鼠准备从出发点吃遍每一个工厂的奶酪。老鼠有一个体力值,初始时为1,每吃一个工厂的奶酪体力值增加1(每个工厂只能吃一次),且老鼠只能吃硬度不大于当前体力值的奶酪。 老鼠从当前格到上下左右相邻的无障碍物的格需要时间1单位,有障碍物的格不能走。走到工厂上时即可吃到该工厂的奶酪,吃奶酪时间...原创 2018-04-10 23:33:29 · 199 阅读 · 0 评论 -
POJ 1979 Red and Black(DFS)
DescriptionThere is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent ti...原创 2018-04-08 16:39:49 · 110 阅读 · 0 评论 -
UVA 10391 Compound Words
DescriptionYou are to find all the two-word compound words in a dictionary. A two-word compound word is aword in the dictionary that is the concatenation of exactly two other words in the dictionar...原创 2018-03-19 15:33:27 · 210 阅读 · 0 评论 -
UVA 10763 Foreign Exchange
DescriptionYour non-profit organization (iCORE - international Confederation of Revolver Enthusiasts) coordinates a very successful foreign student exchange program. Over the last few years, demand ...原创 2018-03-19 15:14:51 · 247 阅读 · 0 评论 -
UVA 10935 Throwing cards away I
DescriptionGiven is an ordered deck of n cards numbered 1to n with card 1 at the top and card n at thebottom. The following operation is performed aslong as there are at least two cards in the deck:...原创 2018-03-19 13:53:14 · 154 阅读 · 0 评论 -
UVA 1594 Ducci Sequence
DescriptionA Ducci sequence is a sequence of n-tuples of integers. Given an n-tuple of integers (a1; a2; · · · ; an),the next n-tuple in the sequence is formed by taking the absolute differences of ...原创 2018-03-19 13:49:17 · 198 阅读 · 0 评论 -
UVA 1593 Alignment of Code
DescriptionYou are working in a team that writes Incredibly Customizable Programming Codewriter (ICPC) which is basically a text editor with bells and whistles. You are working on a module that take...原创 2018-03-19 13:35:57 · 165 阅读 · 0 评论 -
POJ 2485 Highways(Prim)
DescriptionThe island nation of Flatopia is perfectly flat. Unfortunately, Flatopia has no public highways. So the traffic is difficult in Flatopia. The Flatopian government is aware of this problem...原创 2018-07-09 15:14:21 · 144 阅读 · 0 评论 -
百炼 12558:岛屿周长(dfs)
描述用一个n*m的二维数组表示地图,1表示陆地,0代表海水,每一格都表示一个1*1的区域。地图中的格子只能横向或者纵向连接(不能对角连接),连接在一起的陆地称作岛屿,同时整个地图都被海水围绕。假设给出的地图中只会有一个岛屿,并且岛屿中不会有湖(即不会有水被陆地包围的情况出现)。请判断所给定的二维地图中岛屿的周长。输入第一行为n和m,表示地图的大小(1<=n<=100, 1<...原创 2018-07-09 18:50:45 · 656 阅读 · 0 评论 -
NOI 4978:宠物小精灵之收服(DP 01背包 两约束条件)
描述宠物小精灵是一部讲述小智和他的搭档皮卡丘一起冒险的故事。一天,小智和皮卡丘来到了小精灵狩猎场,里面有很多珍贵的野生宠物小精灵。小智也想收服其中的一些小精灵。然而,野生的小精灵并不那么容易被收服。对于每一个野生小精灵而言,小智可能需要使用很多个精灵球才能收服它,而在收服过程中,野生小精灵也会对皮卡丘造成一定的伤害(从而减少皮卡丘的体力)。当皮卡丘的体力小于等于0时,小智就必须结束狩猎...原创 2018-07-17 10:18:32 · 448 阅读 · 0 评论 -
NOI B:DNA排序(暴力)
描述现在有一些长度相等的DNA串(只由ACGT四个字母组成),请将它们按照逆序对的数量多少排序。逆序对指的是字符串A中的两个字符A[i]、A[j],具有i < j 且 A[i] > A[j] 的性质。如字符串”ATCG“中,T和C是一个逆序对,T和G是另一个逆序对,这个字符串的逆序对数为2。输入第1行:两个整数n和m,n(0<n<=50)表示字符串长度,m(...原创 2018-07-15 20:18:33 · 419 阅读 · 0 评论 -
NOI 7113:Charm Bracelet(DP 01背包)
描述Bessie has gone to the mall's jewelry store and spies a charm bracelet. Of course, she'd like to fill it with the best charms possible from the N(1 ≤ N≤ 3,402) available charms. Each charm iin the...原创 2018-07-15 16:37:53 · 491 阅读 · 0 评论 -
NOI 156:LETTERS(dfs)
描述A single-player game is played on a rectangular board divided in R rows and C columns. There is a single uppercase letter (A-Z) written in every position in the board.Before the begging of the game...原创 2018-07-14 16:10:12 · 476 阅读 · 0 评论 -
NOI 21:二维数组右上左下遍历(模拟)
描述给定一个row行col列的整数数组array,要求从array[0][0]元素开始,按从左上到右下的对角线顺序遍历整个数组。输入输入的第一行上有两个整数,依次为row和col。余下有row行,每行包含col个整数,构成一个二维整数数组。(注:输入的row和col保证0 < row < 100, 0 < col < 100)输出按遍历顺序输出每个整数。...原创 2018-07-13 22:17:34 · 697 阅读 · 0 评论 -
百炼 2075:Tangled in Cables(Kruskal)
描述You are the owner of SmallCableCo and have purchased the franchise rights for a small town. Unfortunately, you lack enough funds to start your business properly and are relying on parts you have fou...原创 2018-07-13 21:29:27 · 174 阅读 · 0 评论 -
百炼 1321:棋盘问题(dfs)
描述在一个给定形状的棋盘(形状可能是不规则的)上面摆放棋子,棋子没有区别。要求摆放时任意的两个棋子不能放在棋盘中的同一行或者同一列,请编程求解对于给定形状和大小的棋盘,摆放k个棋子的所有可行的摆放方案C。输入输入含有多组测试数据。每组数据的第一行是两个正整数,n k,用一个空格隔开,表示了将在一个n*n的矩阵内描述棋盘,以及摆放棋子的数目。 n <= 8 , k <= n当为-1 ...原创 2018-07-13 20:10:49 · 177 阅读 · 0 评论 -
NOI 08:病人排队
描述病人登记看病,编写一个程序,将登记的病人按照以下原则排出看病的先后顺序: 1. 老年人(年龄 >= 60岁)比非老年人优先看病。 2. 老年人按年龄从大到小的顺序看病,年龄相同的按登记的先后顺序排序。 3. 非老年人按登记的先后顺序看病。输入第1行,输入一个小于100的正整数,表示病人的个数;后面按照病人登记的先后顺序,每行输入一个病人的信息,包括:一个长度小于10的字符...原创 2018-07-12 21:22:11 · 5232 阅读 · 0 评论 -
百炼 1251:丛林中的路(Kruskal)
描述 热带岛屿Lagrishan的首领现在面临一个问题:几年前,一批外援资金被用于维护村落之间的道路,但日益繁茂的丛林无情的侵蚀着村民的道路,导致道路维修开销巨大,长老会不得不放弃部分道路的维护。上图左侧图显示的是正在使用道路的简图以及每条路每个月的维修费用(单位为aacms)。现在长老会需要提出一种方案,即需要保证村落之间都可以互相到达,又要将每个月的道路维修费用控制在最小。村子编号...原创 2018-07-12 19:37:23 · 844 阅读 · 0 评论 -
NOI25:最长最短单词
描述输入1行句子(不多于200个单词,每个单词长度不超过100),只包含字母、空格和逗号。单词由至少一个连续的字母构成,空格和逗号都是单词间的间隔。试输出第1个最长的单词和第1个最短单词。 输入一行句子。输出两行输出:第1行,第一个最长的单词。第2行,第一个最短的单词。样例输入I am studying Programming language C in Peking Uni...原创 2018-07-11 21:09:01 · 5521 阅读 · 0 评论 -
NOI 22 因子分解
描述输入一个数,输出其素因子分解表达式。输入输入一个整数 n (2 <= n < 100)。输出输出该整数的因子分解表达式。表达式中各个素数从小到大排列。如果该整数可以分解出因子a的b次方,当b大于1时,写做 a^b ;当b等于1时,则直接写成a。样例输入60样例输出2^2*3*5自己写的程序很复杂,调试也一直通不过,附上辣鸡的WA代码与别人写的简...原创 2018-07-11 11:23:15 · 712 阅读 · 0 评论 -
百炼 4078:实现堆结构(模拟堆)
描述定义一个数组,初始化为空。在数组上执行两种操作:1、增添1个元素,把1个新的元素放入数组。2、输出并删除数组中最小的数。使用堆结构实现上述功能的高效算法。输入第一行输入一个整数n,代表操作的次数。每次操作首先输入一个整数type。当type=1,增添操作,接着输入一个整数u,代表要插入的元素。当type=2,输出删除操作,输出并删除数组中最小的元素。1<=n&...原创 2018-07-10 22:00:03 · 1276 阅读 · 1 评论 -
NOI 4977 怪盗基德的滑翔翼(DP)
描述 怪盗基德是一个充满传奇色彩的怪盗,专门以珠宝为目标的超级盗窃犯。而他最为突出的地方,就是他每次都能逃脱中村警部的重重围堵,而这也很大程度上是多亏了他随身携带的便于操作的滑翔翼。有一天,怪盗基德像往常一样偷走了一颗珍贵的钻石,不料却被柯南小朋友识破了伪装,而他的滑翔翼的动力装置也被柯南踢出的足球破坏了。不得已,怪盗基德只能操作受损的滑翔翼逃脱。假设城市中一共有N幢建筑排成一...原创 2018-07-10 11:46:14 · 484 阅读 · 0 评论 -
百炼1248 Safecracker(dfs+暴力)
描述"The item is locked in a Klein safe behind a painting in the second-floor library. Klein safes are extremely rare; most of them, along with Klein and his factory, were destroyed in World War II. F...原创 2018-07-10 09:45:40 · 327 阅读 · 0 评论 -
百炼3251 最少费用(DP)
描述一个商人穿过一个正方形的网格,每经过网格上的一个点需要缴纳一定的费用。每行和每列上的点费用都是按照从小到大顺序排列的,并且对于每个网格上的点,其前后左右的各个点的收费都是不一样的。编写程序设计一个商人总左上角走到右下角花费的最小费用。输入第一行是一个整数,表示正方行的宽度N (N <100),后面n行n列为网格上每个点的费用输出一行,表示最小费用样例输入51 4 6 8...原创 2018-07-07 20:23:29 · 208 阅读 · 0 评论