
UVa
文章平均质量分 88
知足c
Good afternoon, Good evening and Good night~
展开
-
UVa 10069 Distinct Subsequences(大数+DP)
Distinct SubsequencesA subsequence of a given sequence is just the given sequence with some elements (possibly none) left out. Formally, given a sequence X = x1x2…xm, another sequence Z = z1原创 2014-07-21 14:08:43 · 1194 阅读 · 0 评论 -
UVa 401 Palindromes(字符串,回文)
Palindromes A regular palindrome is a string of numbers or letters that is the same forward as backward. For example, the string "ABCDEDCBA" is a palindrome because it is the same when t原创 2014-07-29 20:18:31 · 1043 阅读 · 0 评论 -
UVa 1583 Digit Generator(数)
For a positive integer N , the digit-sum of N is defined as the sum of N itself and its digits. When M is the digitsum of N , we call N a generator of M .For example, the digit-sum of 245 is 256 (原创 2014-07-29 20:59:28 · 878 阅读 · 0 评论 -
UVa 572 Oil Deposits(DFS)
题意 计算@连通块的数量 典型的dfs应用原创 2014-08-04 19:57:38 · 1084 阅读 · 0 评论 -
UVa 1585 Score(水)
ScoreThere is an objective test result such as ``OOXXOXXOOO". An `O' means a correct answer of a problem and an `X' means a wrong answer. The score of each problem of this test is calculated by原创 2014-07-28 20:43:33 · 38155 阅读 · 0 评论 -
UVa 10285 Longest Run on a Snowboard(DP)
题意:在一个矩阵中找出最长递减连续序列,也是较基础的dp;原创 2014-07-10 20:48:27 · 839 阅读 · 0 评论 -
UVa 10066 Twin Towers (最长公共子序列)
又是一道最长公共子序列的题 不用打印路径 相当于DP的水题了原创 2014-07-09 16:46:13 · 729 阅读 · 0 评论 -
UVa 10130 SuperSale(DP_01背包)
很简单的01背包题目 求出每个人可以拿的最大值 加起来就是结果了原创 2014-07-10 08:26:14 · 760 阅读 · 0 评论 -
UVa 156 Ananagrams(STL,map)
题意 给你一篇文章 以"#"号结束 按字典序求输出这篇文章中真正只出现过一次的单词 就是不能通过字母重新排列得到文章中另一个单词的单词把每个单词的字母全部化为小写 再把这个单词中的字母按字典序排列 得到一个字符串 用map记下出现次数就行 只出现过一次的就是要输出的原创 2014-08-04 10:50:22 · 1013 阅读 · 0 评论 -
UVa 340 Master-Mind Hints
Master-Mind Hints MasterMind is a game for two players. One of them, Designer, selects a secret code. The other,Breaker, tries to break it. A code is no more than a row of colored dots.原创 2014-07-30 14:37:53 · 963 阅读 · 0 评论 -
UVa 1584 Circular Sequence(循环串 字典序)
每次后移一位比较字典序即可 注意不能用strcpy(s+1,s)原创 2014-07-30 09:16:24 · 1023 阅读 · 0 评论 -
UVa 679 Dropping Balls
题意 i个小球在一棵二叉树上下落 第奇数个到达某个节点就往左 否则往右 求最后一个小球下落到最底层所在结点的序号对于第i个小球 在根结点处 若i是奇数 则它是往左的第(i+1)/2个小球 若i是偶数 则它是往右的第n/2个小球 而对于一个结点k 它的左子结点序号为2*k 右子节点序号为2*k+1 每次更新i到到最底层就得出结果了原创 2014-08-06 14:51:17 · 1039 阅读 · 0 评论 -
UVa 12657 Boxes in a Line(双向链表的应用)
题意 开始有n个盒子按1到n的顺序排列 对这些盒子进行m次操作 每次为把x移到y的左边 右边 交换x,y 颠倒顺序中的一个求操作完成后所有奇数位原盒子序号的和;直接模拟肯定会超时 用stl中的链表也超时 只能用数组自己模拟一个双向链表了 le[i],ri[i]分别表示第i个盒子左边盒子的序号和右边盒子的序号 代码中有注释原创 2014-08-06 21:14:47 · 1729 阅读 · 0 评论 -
UVa 213 Message Decoding(World Finals1991,字符串)
题意 编写一个解码程序 对数字串进行解码输入第一行是一个解码key key从左到右每个字符分别对应0,00,01,10,000,001,011,100,101,110,0000,0001,...,1101,1110,00000,.......长度为len的字符编码有2^n-1个 而且恰好以二进制方式从0到2^n-2递增 而且字符编码的最大长度为7 可以有2^7-1=127个字符我们只需开一个key[len][val]数组 里面存的是长度为len的第val+1个字符编码 然后解原创 2014-07-31 21:02:23 · 4045 阅读 · 1 评论 -
UVa 489 Hangman Judge(字符串)
一个字符串的游戏 有一个你不知道的字符串 你开始有7条命 然后你每次猜一个字母 若你猜的字母在原字符串中 原字符串就去掉所有那个字母 否则你失去一条命 如果你在命耗完之前原字符串中所有的字母都被猜出 则你赢 如果你在命耗完了原字符串中还有字母没被猜出 则你输 如果你在命没耗完原字符串中也还有字母没被猜出 视为你放弃给你另一个字符串作为你猜的顺序 判断你是否能赢:原创 2014-07-30 18:40:20 · 1134 阅读 · 0 评论 -
UVa 11988 Broken Keyboard(链表的应用)
题意 电脑键盘的home键和end键坏了 会在你不注意时自动按下给你一个输入序列 '['代表home键 ']'代表end键 要求输出屏幕上对应的输出用链表保存每个位置的字符c和下一个位置的编号next 最后一个字符的next为0并用cur表示光标的移动原创 2014-08-06 10:26:58 · 1137 阅读 · 0 评论 -
UVa 1339 Ancient Cipher
Ancient CipherAncient Roman empire had a strong government system with various departments, including a secret service department. Important documents were sent between provinces and the capit原创 2014-07-30 16:06:04 · 1041 阅读 · 0 评论 -
UVa 133 The Dole Queue
N个人按逆时针从一到n排成一个环 官员1从1开始每次逆时针走过k个人 选出停留地方的人 官员2从n开始每次顺时针走过m个人 选出停留地方的人若停留地方相同 则只选出一个人 求这些人被选出的顺序 直接模拟就行了;原创 2014-07-30 22:35:50 · 944 阅读 · 0 评论 -
UVa 514 Rails(经典栈)
有n辆火车 按1到n的顺序进站 最后进站的车可以在任何时候出去 判断给定的出站序列是否可能火车只有两种状态 从A进站 或者从站到B 模拟栈的操作就行了令A表示A中当前待进站的第一辆火车 tar[B]表示出站序列中当前应该出站的火车 sta为火车站当A==tar[B]的时候 A进站马上出战 否则当站中最后一辆==tar[B]时 这辆车出站 都不满足就只能A中的最前面的火车进站当n辆火车全部进站 而站中还有火车是 给定的出战序列就是不可能的原创 2014-08-04 17:07:46 · 1304 阅读 · 0 评论 -
UVa 12412 A Typical Homework(学生信息管理系统)
这种题目出现在oj上感觉挺奇怪的 这不是当年C语言期末考试的题目吗 实在不知道我的代码哪里有问题 样例是一摸一样的可能哪里格式错了吧 既然是个系统就不在乎那些了TT原创 2014-08-03 15:45:44 · 4728 阅读 · 0 评论 -
UVA 103 Stacking Boxes 堆砌盒子(DP)
Stacking Boxes BackgroundSome concepts in Mathematics and Computer Science are simple in one or two dimensions but become more complex when extended to arbitrary dimensions. Consider s原创 2014-07-06 19:59:58 · 633 阅读 · 0 评论 -
UVa 10534 Wavio Sequence (最长递增子序列 DP 二分)
Wavio Sequence Wavio is a sequence of integers. It has some interesting properties.· Wavio is of odd length i.e. L = 2*n + 1.· The first (n+1) integers of Wavio sequence makes a strictly i原创 2014-07-22 09:14:55 · 1174 阅读 · 0 评论 -
UVa 437 The Tower of Babylon(动态规划)
The Tower of Babylon Perhaps you have heard of the legend of the Tower of Babylon. Nowadays many details of this tale have been forgotten. So now, in line with the educational nature of th原创 2014-07-11 15:40:06 · 847 阅读 · 0 评论 -
UVa 825 Walking on the Safe Side(DP)
Square City is a very easy place for people to walk around. The two-way streets run North-South or East-West dividing the city into regular blocks. Most street int原创 2014-07-20 21:20:11 · 1112 阅读 · 0 评论 -
UVa 620 Cellular Structure(DP)
有A,B两种细胞 A细胞可由空生成 非原创 2014-07-20 14:56:51 · 740 阅读 · 0 评论 -
UVa 10404 Bachet's Game(DP)
Bachet's GameBachet's game is probably known to all but probably not by this name. Initially there are nstones on the table. There are two players Stan and Ollie, who move alternately. Stan always原创 2014-07-20 09:10:08 · 908 阅读 · 0 评论 -
UVA 624 CD 01背包(DP)
CD You have a long drive by car ahead. You have a tape recorder, but unfortunately your best music is on CDs. You need to have it on tapes so the problem to solve is: you have a tape N m原创 2014-07-06 10:47:16 · 698 阅读 · 0 评论 -
UVa 10051 Tower of Cubes(DP 最长序列)
Problem A: Tower of Cubes In this problem you are given N colorful cubes each having a distinct weight. Each face of a cube is colored with one color. Your job is to build a tower using th原创 2014-07-23 15:06:11 · 1062 阅读 · 0 评论 -
UVa 10651 Pebble Solitaire(DP 记忆化搜索)
Pebble Solitaire Pebble solitaire is an interesting game. This is a game where you are given a board with an arrangement of small cavities, initially all but one occupied by a pebble each. The原创 2014-07-23 21:30:30 · 1065 阅读 · 0 评论 -
UVA 10192 Vacation 最长公共子序列(DP)
Problem E: Vacation The ProblemYou are planning to take some rest and to go out on vacation, but you really don't know which cities you should visit. So, you ask your parents for原创 2014-07-06 13:49:35 · 690 阅读 · 0 评论 -
UVA 531 Compromise 最长公共子序列(DP)
Compromise In a few months the European Currency Union will become a reality. However, to join the club, the Maastricht criteria must be fulfilled, and this is not a trivial task for the c原创 2014-07-06 17:59:01 · 738 阅读 · 0 评论 -
UVa 116 Unidirectional TSP(DP)
ji原创 2014-07-09 16:02:56 · 766 阅读 · 0 评论 -
UVa 348 最优矩阵链乘 (DP)
矩阵链乘在小白P170有讲解 也是经典的动态规划 有了转移原创 2014-07-09 21:15:27 · 913 阅读 · 0 评论 -
UVA 10131 Is Bigger Smarter? (DP)
Question 1: Is Bigger Smarter?The ProblemSome people think that the bigger an elephant is, the smarter it is. To disprove this, you want to take the data on a collection of elephants and put a原创 2014-07-06 09:23:49 · 573 阅读 · 0 评论 -
UVA 147 Dollars 基础DP(水)
Dollars New Zealand currency consists of $100, $50, $20, $10, and $5 notes and $2, $1, 50c, 20c, 10c and 5c coins. Write a program that will determine, for any given amount, in how many原创 2014-07-05 20:38:00 · 784 阅读 · 0 评论 -
UVa 147 Dollars(DP完全背包)
Dollars New Zealand currency consists of $100, $50, $20, $10, and $5 notes and $2, $1, 50c, 20c, 10c and 5c coins. Write a program that will determine, for any given amount, in how many wa原创 2014-07-09 21:39:51 · 751 阅读 · 0 评论 -
UVa 10465 Homer Simpson(DP完全背包)
题意 原创 2014-07-10 16:05:09 · 789 阅读 · 0 评论 -
POJ 3481 Double Queue(STL)
题意 模拟银行的排队系统 有三种操作 1-添加优先级为p 编号为k的人到队列 2-服务当前优先级最大的 3-服务当前优先级最小的 0-退出系统可以用stl中的map 因为map本身就根据key的值排了序 对应2,3 我们只需要输出最大或最小就行了并从map中删除该键值#include#includeusing namespace std;map a;int原创 2014-08-15 13:56:23 · 1532 阅读 · 0 评论