06 2018 档案

摘要:In graph theory, an Eulerian path is a path in a graph which visits every edge exactly once. Similarly, an Eulerian circuit is an Eulerian path which 阅读全文
posted @ 2018-06-28 20:27 赖兴宇 阅读(1180) 评论(0) 推荐(0)
摘要:Input our current position and a destination, an online map can recommend several paths. Now your job is to recommend two paths to your user: one is t 阅读全文
posted @ 2018-06-28 19:46 赖兴宇 阅读(303) 评论(0) 推荐(0)
摘要:A gas station has to be built at such a location that the minimum distance between the station and any of the residential housing is as far away as po 阅读全文
posted @ 2018-06-28 17:57 赖兴宇 阅读(211) 评论(0) 推荐(0)
摘要:It is vitally important to have all the cities connected by highways in a war. If a city is occupied by the enemy, all the highways from/toward that c 阅读全文
posted @ 2018-06-28 15:24 赖兴宇 阅读(168) 评论(0) 推荐(0)
摘要:As an emergency rescue team leader of a city, you are given a special map of your country. The map shows several scattered cities connected by some ro 阅读全文
posted @ 2018-06-28 10:56 赖兴宇 阅读(329) 评论(0) 推荐(0)
摘要:Weibo is known as the Chinese version of Twitter. One user on Weibo may have many followers, and may follow many other users as well. Hence a social n 阅读全文
posted @ 2018-06-28 01:34 赖兴宇 阅读(162) 评论(0) 推荐(0)
摘要:One way that the police finds the head of a gang is to check people's phone calls. If there is a phone call between A and B, we say that A and B is re 阅读全文
posted @ 2018-06-28 00:54 赖兴宇 阅读(161) 评论(0) 推荐(0)
摘要:An AVL tree is a self-balancing binary search tree. In an AVL tree, the heights of the two child subtrees of any node differ by at most one; if at any 阅读全文
posted @ 2018-06-27 13:00 赖兴宇 阅读(178) 评论(0) 推荐(0)
摘要:On a broken keyboard, some of the keys are always stucked. So when you type some sentences, the characters corresponding to those keys will appear rep 阅读全文
posted @ 2018-06-27 11:12 赖兴宇 阅读(294) 评论(0) 推荐(1)
摘要:继续加油 2018/6/27 阅读全文
posted @ 2018-06-27 10:25 赖兴宇 阅读(272) 评论(0) 推荐(0)
摘要:1110 Complete Binary Tree (25)(25 分) Given a tree, you are supposed to tell if it is a complete binary tree. Input Specification: Each input file cont 阅读全文
posted @ 2018-06-27 10:24 赖兴宇 阅读(221) 评论(0) 推荐(0)
摘要:The basic task is simple: given N real numbers, you are supposed to calculate their average. But what makes it complicated is that some of the input n 阅读全文
posted @ 2018-06-27 09:11 赖兴宇 阅读(153) 评论(0) 推荐(0)
摘要:People on Mars count their numbers with base 13: Zero on Earth is called "tret" on Mars. The numbers 1 to 12 on Earch is called "jan, feb, mar, apr, m 阅读全文
posted @ 2018-06-27 08:36 赖兴宇 阅读(145) 评论(0) 推荐(0)
摘要:An inorder binary tree traversal can be implemented in a non-recursive way with a stack. For example, suppose that when a 6-node binary tree (with the 阅读全文
posted @ 2018-06-26 23:13 赖兴宇 阅读(177) 评论(0) 推荐(0)
摘要:A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties: The left subtree of a node contains only nodes 阅读全文
posted @ 2018-06-26 22:16 赖兴宇 阅读(259) 评论(0) 推荐(0)
摘要:People often have a preference among synonyms of the same word. For example, some may prefer "the police", while others may prefer "the cops". Analyzi 阅读全文
posted @ 2018-06-26 21:21 赖兴宇 阅读(162) 评论(0) 推荐(0)
摘要:The Japanese language is notorious for its sentence ending particles. Personal preference of such particles can be considered as a reflection of the s 阅读全文
posted @ 2018-06-26 18:15 赖兴宇 阅读(178) 评论(0) 推荐(0)
摘要:A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties: The left subtree of a node contains only nodes 阅读全文
posted @ 2018-06-26 15:58 赖兴宇 阅读(166) 评论(0) 推荐(0)
摘要:1053 Path of Equal Weight (30)(30 分) Given a non-empty tree with root R, and with weight W~i~ assigned to each tree node T~i~. The weight of a path fr 阅读全文
posted @ 2018-06-26 14:36 赖兴宇 阅读(148) 评论(0) 推荐(0)
摘要:vector: 在vc6中,如果要镶嵌使用vector, 如vector<vector<int> >, 后面的两个> 应该用,空格隔开, 否则被编译器认为是移位符 string::npos 的值为-1或者4294967295 string str; str.find(str2) 返回str2第一次在 阅读全文
posted @ 2018-06-25 21:40 赖兴宇 阅读(377) 评论(0) 推荐(0)
摘要:最大公约数:辗转相除法, 0和a的最大公因子为a; a和b的最小公倍数: 设a,b的最大公因子为d, 则最小公倍数为ab/d, 但是ab可能会导致溢出,应该先算除法再算乘法,即最小公倍数为a/d*b 分数运算: 用结构体保存分子,分母;为了避免乘法溢出, 分子分母用long long 保存, 满足以 阅读全文
posted @ 2018-06-25 19:43 赖兴宇 阅读(316) 评论(0) 推荐(0)
摘要:Given any positive integer N, you are supposed to find all of its prime factors, and write them in the format N = p~1~\^k~1~ * p~2~\^k~2~ *…*p~m~\^k~m 阅读全文
posted @ 2018-06-25 19:42 赖兴宇 阅读(687) 评论(0) 推荐(0)
摘要:rand()能输出的最大随机数是32767, 如果要生成最大的随机数应该采用下面的方法 阅读全文
posted @ 2018-06-25 16:33 赖兴宇 阅读(620) 评论(0) 推荐(0)
摘要:给定一句英语,要求你编写程序,将句中所有单词的顺序颠倒输出。 输入格式:测试输入包含一个测试用例,在一行内给出总长度不超过80的字符串。字符串由若干单词和若干空格组成,其中单词是由英文字母(大小写有区分)组成的字符串,单词之间用1个空格分开,输入保证句子末尾没有多余的空格。 输出格式:每个测试用例的 阅读全文
posted @ 2018-06-24 23:39 赖兴宇 阅读(185) 评论(0) 推荐(0)
摘要:mid=(l+r)/2可能会出错, 应该用mid=l+(r-l)/2; 阅读全文
posted @ 2018-06-24 17:23 赖兴宇 阅读(139) 评论(0) 推荐(0)
摘要:Given an unsorted array of integers, find the length of longest increasing subsequence. Example: Note: There may be more than one LIS combination, it 阅读全文
posted @ 2018-06-24 17:11 赖兴宇 阅读(181) 评论(0) 推荐(0)
摘要:Given an integer array with all positive numbers and no duplicates, find the number of possible combinations that add up to a positive integer target. 阅读全文
posted @ 2018-06-24 15:23 赖兴宇 阅读(193) 评论(0) 推荐(0)
摘要:Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent. A mapping of digit to le 阅读全文
posted @ 2018-06-24 14:32 赖兴宇 阅读(209) 评论(0) 推荐(0)
摘要:to be continued 阅读全文
posted @ 2018-06-23 21:55 赖兴宇 阅读(190) 评论(0) 推荐(0)
摘要:Given a string of numbers and operators, return all possible results from computing all the different possible ways to group numbers and operators. Th 阅读全文
posted @ 2018-06-23 21:23 赖兴宇 阅读(228) 评论(0) 推荐(0)
摘要:Given an array of size n, find the majority element. The majority element is the element that appears more than⌊ n/2 ⌋ times. You may assume that the 阅读全文
posted @ 2018-06-23 20:51 赖兴宇 阅读(166) 评论(0) 推荐(0)
摘要:Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum. Example: Inpu 阅读全文
posted @ 2018-06-23 20:40 赖兴宇 阅读(168) 评论(0) 推荐(0)
摘要:1096 Consecutive Factors (20)(20 分) Among all the factors of a positive integer N, there may exist several consecutive numbers. For example, 630 can b 阅读全文
posted @ 2018-06-23 15:36 赖兴宇 阅读(518) 评论(0) 推荐(0)
摘要:Mice and Rice is the name of a programming contest in which each programmer must write a piece of code to control the movements of a mouse in a given 阅读全文
posted @ 2018-06-23 14:45 赖兴宇 阅读(164) 评论(0) 推荐(0)
摘要:Given a string, you are supposed to output the length of the longest symmetric sub-string. For example, given "Is PAT&TAP symmetric?", the longest sym 阅读全文
posted @ 2018-06-23 13:11 赖兴宇 阅读(118) 评论(0) 推荐(0)
摘要:Eva loves to collect coins from all over the universe, including some other planets like Mars. One day she visited a universal shopping mall which cou 阅读全文
posted @ 2018-06-23 12:44 赖兴宇 阅读(174) 评论(0) 推荐(0)
摘要:Eva loves to collect coins from all over the universe, including some other planets like Mars. One day she visited a universal shopping mall which cou 阅读全文
posted @ 2018-06-22 20:36 赖兴宇 阅读(142) 评论(0) 推荐(0)
摘要:The "eight queens puzzle" is the problem of placing eight chess queens on an 8×8 chessboard so that no two queens threaten each other. Thus, a solutio 阅读全文
posted @ 2018-06-22 20:22 赖兴宇 阅读(198) 评论(0) 推荐(0)
摘要:Shopping in Mars is quite a different experience. The Mars people pay by chained diamonds. Each diamond has a value (in Mars dollars M\$). When making 阅读全文
posted @ 2018-06-22 19:08 赖兴宇 阅读(152) 评论(0) 推荐(0)
摘要:Suppose that all the keys in a binary tree are distinct positive integers. Given the postorder and inorder traversal sequences, you are supposed to ou 阅读全文
posted @ 2018-06-22 16:51 赖兴宇 阅读(172) 评论(0) 推荐(0)
摘要:Suppose that all the keys in a binary tree are distinct positive integers. A unique binary tree can be determined by a given pair of postorder and ino 阅读全文
posted @ 2018-06-22 16:33 赖兴宇 阅读(294) 评论(0) 推荐(0)
摘要:The following is from Max Howell @twitter: Google: 90% of our engineers use the software you wrote (Homebrew), but you can't invert a binary tree on a 阅读全文
posted @ 2018-06-22 15:09 赖兴宇 阅读(159) 评论(0) 推荐(0)
摘要:给定一个三角形,找出自顶向下的最小路径和。每一步只能移动到下一行中相邻的结点上。 例如,给定三角形: 自顶向下的最小路径和为 11(即,2 + 3 + 5 + 1 = 11)。 说明: 如果你可以只使用 O(n) 的额外空间(n 为三角形的总行数)来解决这个问题,那么你的算法会很加分。 dp1[i] 阅读全文
posted @ 2018-06-22 13:34 赖兴宇 阅读(191) 评论(0) 推荐(0)
摘要:一条包含字母 A-Z 的消息通过以下方式进行了编码: 给定一个只包含数字的非空字符串,请计算解码方法的总数。 示例 1: 示例 2: 阅读全文
posted @ 2018-06-21 23:04 赖兴宇 阅读(265) 评论(0) 推荐(0)
摘要:给定一个包含非负整数的 m x n 网格,请找出一条从左上角到右下角的路径,使得路径上的数字总和为最小。 说明:每次只能向下或者向右移动一步。 示例: 阅读全文
posted @ 2018-06-21 21:01 赖兴宇 阅读(135) 评论(0) 推荐(0)
摘要:一个机器人位于一个 m x n 网格的左上角 (起始点在下图中标记为“Start” )。 机器人每次只能向下或者向右移动一步。机器人试图达到网格的右下角(在下图中标记为“Finish”)。 现在考虑网格中有障碍物。那么从左上角到右下角将会有多少条不同的路径? 网格中的障碍物和空位置分别用 1 和 0 阅读全文
posted @ 2018-06-21 20:48 赖兴宇 阅读(265) 评论(0) 推荐(0)
摘要:一个机器人位于一个 m x n 网格的左上角 (起始点在下图中标记为“Start” )。 机器人每次只能向下或者向右移动一步。机器人试图达到网格的右下角(在下图中标记为“Finish”)。 问总共有多少条不同的路径? 例如,上图是一个7 x 3 的网格。有多少可能的路径? 说明:m 和 n 的值均不 阅读全文
posted @ 2018-06-21 20:19 赖兴宇 阅读(198) 评论(0) 推荐(0)
摘要:给定一个整数 n,求以 1 ... n 为节点组成的二叉搜索树有多少种? 示例: 阅读全文
posted @ 2018-06-20 12:10 赖兴宇 阅读(974) 评论(0) 推荐(0)
摘要:你是一个专业的小偷,计划偷窃沿街的房屋,每间房内都藏有一定的现金。这个地方所有的房屋都围成一圈,这意味着第一个房屋和最后一个房屋是紧挨着的。同时,相邻的房屋装有相互连通的防盗系统,如果两间相邻的房屋在同一晚上被小偷闯入,系统会自动报警。 给定一个代表每个房屋存放金额的非负整数数组,计算你在不触动警报 阅读全文
posted @ 2018-06-20 11:56 赖兴宇 阅读(473) 评论(0) 推荐(0)
摘要:你是一个专业的小偷,计划偷窃沿街的房屋。每间房内都藏有一定的现金,影响你偷窃的唯一制约因素就是相邻的房屋装有相互连通的防盗系统,如果两间相邻的房屋在同一晚上被小偷闯入,系统会自动报警。 给定一个代表每个房屋存放金额的非负整数数组,计算你在不触动警报装置的情况下,能够偷窃到的最高金额。 示例 1: 输 阅读全文
posted @ 2018-06-20 11:33 赖兴宇 阅读(215) 评论(0) 推荐(0)
摘要:给定一个数组,它的第 i 个元素是一支给定的股票在第 i 天的价格。 设计一个算法来计算你所能获取的最大利润。你最多可以完成 k 笔交易。 注意: 你不能同时参与多笔交易(你必须在再次购买前出售掉之前的股票)。 示例 1: 示例 2: 阅读全文
posted @ 2018-06-20 00:30 赖兴宇 阅读(383) 评论(0) 推荐(0)
摘要:给定一个数组,它的第 i 个元素是一支给定的股票在第 i 天的价格。 设计一个算法来计算你所能获取的最大利润。你最多可以完成 两笔 交易。 注意: 你不能同时参与多笔交易(你必须在再次购买前出售掉之前的股票)。 示例 1: 示例 2: 示例 3: 阅读全文
posted @ 2018-06-20 00:10 赖兴宇 阅读(201) 评论(0) 推荐(0)
摘要:给定一个数组,它的第 i 个元素是一支给定股票第 i 天的价格。 如果你最多只允许完成一笔交易(即买入和卖出一支股票),设计一个算法来计算你所能获取的最大利润。 注意你不能在买入股票前卖出股票。 示例 1: 示例 2: 阅读全文
posted @ 2018-06-19 23:53 赖兴宇 阅读(165) 评论(0) 推荐(0)
摘要:在未排序的数组中找到第 k 个最大的元素。请注意,你需要找的是数组排序后的第 k 个最大的元素,而不是第 k 个不同的元素。 示例 1: 示例 2: 说明: 你可以假设 k 总是有效的,且 1 ≤ k ≤ 数组的长度。 最粗暴的方式是对所有的数据排序,然后取出第k个数;但是对进行很多不必要的排序; 阅读全文
posted @ 2018-06-19 23:26 赖兴宇 阅读(179) 评论(0) 推荐(0)
摘要:Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000. Example 1: Example 2: 阅读全文
posted @ 2018-06-18 23:22 赖兴宇 阅读(162) 评论(0) 推荐(0)
摘要:Given N integers, you are supposed to find the smallest positive integer that is NOT in the given list. Input Specification: Each input file contains 阅读全文
posted @ 2018-06-14 18:25 赖兴宇 阅读(742) 评论(0) 推荐(0)
摘要:Zhejiang University has 6 campuses and a lot of gates. From each gate we can collect the in/out times and the plate numbers of the cars crossing the g 阅读全文
posted @ 2018-06-14 16:54 赖兴宇 阅读(353) 评论(0) 推荐(0)
摘要:It is said that in 2013, there were about 100 graduate schools ready to proceed over 40,000 applications in Zhejiang Province. It would help a lot if 阅读全文
posted @ 2018-06-14 11:51 赖兴宇 阅读(367) 评论(0) 推荐(0)
摘要:A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties: The left subtree of a node contains only nodes 阅读全文
posted @ 2018-06-14 10:12 赖兴宇 阅读(190) 评论(0) 推荐(0)
摘要:There is a public bike service in Hangzhou City which provides great convenience to the tourists from all over the world. One may rent a bike at any s 阅读全文
posted @ 2018-06-14 00:58 赖兴宇 阅读(373) 评论(0) 推荐(0)
摘要:Indeed there are many different tourist routes from our city to Rome. You are supposed to find your clients the route with the least cost while gainin 阅读全文
posted @ 2018-06-13 23:07 赖兴宇 阅读(235) 评论(0) 推荐(0)
摘要:A traveler's map gives the distances between cities along the highways, together with the cost of each highway. Now you are supposed to write a progra 阅读全文
posted @ 2018-06-13 21:17 赖兴宇 阅读(639) 评论(0) 推荐(0)
摘要:Given a singly linked list, you are supposed to rearrange its elements so that all the negative values appear before all of the non-negatives, and all 阅读全文
posted @ 2018-06-13 19:22 赖兴宇 阅读(255) 评论(0) 推荐(0)
摘要:Given two strings S~1~ and S~2~, S = S~1~ - S~2~ is defined to be the remaining string after taking all the characters in S~2~ from S~1~. Your task is 阅读全文
posted @ 2018-06-13 17:09 赖兴宇 阅读(126) 评论(0) 推荐(0)
摘要:Shuffling is a procedure used to randomize a deck of playing cards. Because standard shuffling techniques are seen as weak, and in order to avoid "ins 阅读全文
posted @ 2018-06-13 16:59 赖兴宇 阅读(196) 评论(0) 推荐(0)
摘要:To prepare for PAT, the judge sometimes has to generate random passwords for the users. The problem is that there are always some confusing passwords 阅读全文
posted @ 2018-06-13 16:53 赖兴宇 阅读(155) 评论(0) 推荐(0)
摘要:Notice that the number 123456789 is a 9-digit number consisting exactly the numbers from 1 to 9, with no duplication. Double it we will obtain 2469135 阅读全文
posted @ 2018-06-13 16:25 赖兴宇 阅读(189) 评论(0) 推荐(0)
摘要:Given a non-negative integer N, your task is to compute the sum of all the digits of N, and output every digit of the sum in English. Input Specificat 阅读全文
posted @ 2018-06-13 16:05 赖兴宇 阅读(160) 评论(0) 推荐(0)
摘要:Eva would like to make a string of beads with her favorite colors so she went to a small shop to buy some beads. There were many colorful strings of b 阅读全文
posted @ 2018-06-13 15:52 赖兴宇 阅读(190) 评论(0) 推荐(0)
摘要:Some scientists took pictures of thousands of birds in a forest. Assume that all the birds appear in the same picture belong to the same tree. You are 阅读全文
posted @ 2018-06-13 15:41 赖兴宇 阅读(209) 评论(0) 推荐(0)
摘要:Given a syntax tree (binary), you are supposed to output the corresponding infix expression, with parentheses reflecting the precedences of the operat 阅读全文
posted @ 2018-06-13 14:23 赖兴宇 阅读(172) 评论(0) 推荐(0)
摘要:Given N rational numbers in the form "numerator/denominator", you are supposed to calculate their sum. Input Specification: Each input file contains o 阅读全文
posted @ 2018-06-12 22:42 赖兴宇 阅读(240) 评论(0) 推荐(0)
摘要:Given a sequence of positive integers and another positive integer p. The sequence is said to be a "perfect sequence" if M <= m * p where M and m are 阅读全文
posted @ 2018-06-12 22:20 赖兴宇 阅读(194) 评论(0) 推荐(0)
摘要:Formation is very important when taking a group photo. Given the rules of forming K rows with N people as the following: The number of people in each 阅读全文
posted @ 2018-06-12 21:16 赖兴宇 阅读(197) 评论(0) 推荐(0)
摘要:Scientific notation is the way that scientists easily handle very large numbers or very small numbers. The notation matches the regular expression [+- 阅读全文
posted @ 2018-06-12 20:03 赖兴宇 阅读(184) 评论(0) 推荐(0)
摘要:Mooncake is a Chinese bakery product traditionally eaten during the Mid-Autumn Festival. Many types of fillings and crusts can be found in traditional 阅读全文
posted @ 2018-06-12 19:27 赖兴宇 阅读(166) 评论(0) 推荐(0)
摘要:About 900 years ago, a Chinese philosopher Sima Guang wrote a history book in which he talked about people's talent and virtue. According to his theor 阅读全文
posted @ 2018-06-12 17:50 赖兴宇 阅读(210) 评论(0) 推荐(0)
摘要:1137 Final Grading (25)(25 分) For a student taking the online course "Data Structures" on China University MOOC (http://www.icourse163.org/), to be qu 阅读全文
posted @ 2018-06-11 19:28 赖兴宇 阅读(203) 评论(0) 推荐(0)
摘要:Given a set of N (> 1) positive integers, you are supposed to partition them into two disjoint sets A~1~ and A~2~ of n~1~ and n~2~ numbers, respective 阅读全文
posted @ 2018-06-11 18:12 赖兴宇 阅读(177) 评论(0) 推荐(0)
摘要:Given a singly linked list L with integer keys, you are supposed to remove the nodes with duplicated absolute values of the keys. That is, for each va 阅读全文
posted @ 2018-06-11 15:03 赖兴宇 阅读(153) 评论(0) 推荐(0)
摘要:Given a constant K and a singly linked list L, you are supposed to reverse the links of every K elements on L. For example, given L being 1→2→3→4→5→6, 阅读全文
posted @ 2018-06-11 12:10 赖兴宇 阅读(169) 评论(0) 推荐(0)
摘要:To store English words, one method is to use linked lists and store a word letter by letter. To save some space, we may let the words share the same s 阅读全文
posted @ 2018-06-11 11:04 赖兴宇 阅读(238) 评论(0) 推荐(0)
摘要:If a machine can save only 3 significant digits, the float numbers 12300 and 12358.9 are considered equal since they are both saved as 0.123*10^5^ wit 阅读全文
posted @ 2018-06-11 10:46 赖兴宇 阅读(310) 评论(0) 推荐(0)
摘要:Look-and-say sequence is a sequence of integers as the following: D, D1, D111, D113, D11231, D112213111, ... where D is in [0, 9] except 1. The (n+1)s 阅读全文
posted @ 2018-06-10 23:38 赖兴宇 阅读(178) 评论(0) 推荐(0)
摘要:After each PAT, the PAT Center will announce the ranking of institutions based on their students' performances. Now you are asked to generate the rank 阅读全文
posted @ 2018-06-10 21:47 赖兴宇 阅读(270) 评论(0) 推荐(0)
摘要:Given a list of N student records with name, ID and grade. You are supposed to sort the records with respect to the grade in non-increasing order, and 阅读全文
posted @ 2018-06-10 18:05 赖兴宇 阅读(143) 评论(0) 推荐(0)
摘要:This time you are asked to tell the difference between the lowest grade of all the male students and the highest grade of all the female students. Inp 阅读全文
posted @ 2018-06-10 17:07 赖兴宇 阅读(172) 评论(0) 推荐(0)
摘要:A linked list consists of a series of structures, which are not necessarily adjacent in memory. We assume that each structure contains an integer key 阅读全文
posted @ 2018-06-10 16:54 赖兴宇 阅读(166) 评论(0) 推荐(0)
摘要:Excel can sort records according to any column. Now you are supposed to imitate this function. Input Each input file contains one test case. For each 阅读全文
posted @ 2018-06-10 16:25 赖兴宇 阅读(174) 评论(0) 推荐(0)
摘要:Programming Ability Test (PAT) is organized by the College of Computer Science and Technology of Zhejiang University. Each test is supposed to run sim 阅读全文
posted @ 2018-06-09 22:55 赖兴宇 阅读(540) 评论(0) 推荐(0)
摘要:Consider a positive integer N written in standard notation with k+1 digits a~i~ as a~k~...a~1~a~0~ with 0 <= a~i~ < 10 for all i and a~k~ > 0. Then N 阅读全文
posted @ 2018-06-09 22:22 赖兴宇 阅读(211) 评论(0) 推荐(0)
摘要:Cutting an integer means to cut a K digits long integer Z into two integers of (K/2) digits long integers A and B. For example, after cutting Z = 1673 阅读全文
posted @ 2018-06-09 21:39 赖兴宇 阅读(140) 评论(0) 推荐(0)
摘要:"Let's C" is a popular and fun programming contest hosted by the College of Computer Science and Technology, Zhejiang University. Since the idea of th 阅读全文
posted @ 2018-06-09 21:26 赖兴宇 阅读(154) 评论(0) 推荐(0)
摘要:Given some segments of rope, you are supposed to chain them into one rope. Each time you may only fold two segments into loops and chain them into one 阅读全文
posted @ 2018-06-09 20:56 赖兴宇 阅读(159) 评论(0) 推荐(0)
摘要:A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in moving a product from supplier to customer 阅读全文
posted @ 2018-06-09 20:46 赖兴宇 阅读(160) 评论(0) 推荐(0)
摘要:British astronomer Eddington liked to ride a bike. It is said that in order to show off his skill, he has even defined an "Eddington number", E -- tha 阅读全文
posted @ 2018-06-09 20:34 赖兴宇 阅读(178) 评论(0) 推荐(0)
摘要:Given three integers A, B and C in [-2^63^, 2^63^], you are supposed to tell whether A+B > C. Input Specification: The first line of the input gives t 阅读全文
posted @ 2018-06-09 20:20 赖兴宇 阅读(214) 评论(0) 推荐(0)
摘要:Two integers are called "friend numbers" if they share the same sum of their digits, and the sum is their "friend ID". For example, 123 and 51 are fri 阅读全文
posted @ 2018-06-09 19:57 赖兴宇 阅读(173) 评论(0) 推荐(0)
摘要:A family hierarchy is usually presented by a pedigree tree where all the nodes on the same level belong to the same generation. Your task is to find t 阅读全文
posted @ 2018-06-09 19:38 赖兴宇 阅读(133) 评论(0) 推荐(0)
摘要:A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in moving a product from supplier to customer 阅读全文
posted @ 2018-06-09 19:17 赖兴宇 阅读(144) 评论(0) 推荐(0)
摘要:1069 The Black Hole of Numbers (20)(20 分) For any 4-digit integer except the ones with all the digits being the same, if we sort the digits in non-inc 阅读全文
posted @ 2018-06-09 18:59 赖兴宇 阅读(145) 评论(0) 推荐(0)
摘要:For two rational numbers, your task is to implement the basic arithmetics, that is, to calculate their sum, difference, product and quotient. Input Sp 阅读全文
posted @ 2018-06-09 16:59 赖兴宇 阅读(129) 评论(0) 推荐(0)
摘要:A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties: The left subtree of a node contains only nodes 阅读全文
posted @ 2018-06-08 22:55 赖兴宇 阅读(261) 评论(0) 推荐(0)
摘要:On a broken keyboard, some of the keys are worn out. So when you type some sentences, the characters corresponding to those keys will not appear on sc 阅读全文
posted @ 2018-06-08 22:30 赖兴宇 阅读(143) 评论(0) 推荐(0)
摘要:The task of this problem is simple: insert a sequence of distinct positive integers into a hash table, and output the positions of the input numbers. 阅读全文
posted @ 2018-06-08 22:06 赖兴宇 阅读(170) 评论(0) 推荐(0)
摘要:An AVL tree is a self-balancing binary search tree. In an AVL tree, the heights of the two child subtrees of any node differ by at most one; if at any 阅读全文
posted @ 2018-06-08 20:49 赖兴宇 阅读(162) 评论(0) 推荐(0)
摘要:Zhejiang University has 40000 students and provides 2500 courses. Now given the registered course list of each student, you are supposed to output the 阅读全文
posted @ 2018-06-08 19:08 赖兴宇 阅读(177) 评论(0) 推荐(0)
摘要:Given two sets of integers, the similarity of the sets is defined to be N~c~/N~t~*100%, where N~c~ is the number of distinct common numbers shared by 阅读全文
posted @ 2018-06-08 17:02 赖兴宇 阅读(353) 评论(0) 推荐(0)
摘要:Zhejiang University has 40000 students and provides 2500 courses. Now given the student name lists of all the courses, you are supposed to output the 阅读全文
posted @ 2018-06-08 13:57 赖兴宇 阅读(198) 评论(0) 推荐(0)
摘要:Given a collection of number segments, you are supposed to recover the smallest number from them. For example, given {32, 321, 3214, 0229, 87}, we can 阅读全文
posted @ 2018-06-08 13:20 赖兴宇 阅读(143) 评论(0) 推荐(0)
摘要:The magic shop in Mars is offering some magic coupons. Each coupon has an integer N printed on it, meaning that when you use this coupon with a produc 阅读全文
posted @ 2018-06-08 13:08 赖兴宇 阅读(508) 评论(0) 推荐(0)
摘要:A number that will be the same when it is written forwards or backwards is known as a Palindromic Number. For example, 1234321 is a palindromic number 阅读全文
posted @ 2018-06-08 12:45 赖兴宇 阅读(270) 评论(0) 推荐(0)
摘要:Given a stack which can keep M numbers at most. Push N numbers in the order of 1, 2, 3, ..., N and pop randomly. You are supposed to tell if a given s 阅读全文
posted @ 2018-06-08 00:26 赖兴宇 阅读(181) 评论(0) 推荐(0)
摘要:A number that will be the same when it is written forwards or backwards is known as a Palindromic Number. For example, 1234321 is a palindromic number 阅读全文
posted @ 2018-06-07 23:13 赖兴宇 阅读(151) 评论(0) 推荐(0)
摘要:Given any string of N (>=5) characters, you are asked to form the characters into the shape of U. For example, "helloworld" can be printed as: That is 阅读全文
posted @ 2018-06-07 22:59 赖兴宇 阅读(130) 评论(0) 推荐(0)
摘要:To evaluate the performance of our first year CS majored students, we consider their grades of three courses only: C - C Programming Language, M - Mat 阅读全文
posted @ 2018-06-07 22:25 赖兴宇 阅读(136) 评论(0) 推荐(0)
摘要:With the 2010 FIFA World Cup running, football fans the world over were becoming increasingly excited as the best players from the best teams doing ba 阅读全文
posted @ 2018-06-07 21:23 赖兴宇 阅读(373) 评论(0) 推荐(0)
摘要:This time, you are supposed to find A*B where A and B are two polynomials. Input Specification: Each input file contains one test case. Each case occu 阅读全文
posted @ 2018-06-07 21:11 赖兴宇 阅读(148) 评论(0) 推荐(0)
摘要:At the beginning of every day, the first person who signs in the computer room will unlock the door, and the last one who signs out will lock the door 阅读全文
posted @ 2018-06-07 20:33 赖兴宇 阅读(156) 评论(0) 推荐(0)
摘要:A family hierarchy is usually presented by a pedigree tree. Your job is to count those family members who have no child. Input Each input file contain 阅读全文
posted @ 2018-06-07 20:15 赖兴宇 阅读(151) 评论(0) 推荐(0)
摘要:This time, you are supposed to find A+B where A and B are two polynomials. Input Each input file contains one test case. Each case occupies 2 lines, a 阅读全文
posted @ 2018-06-07 19:53 赖兴宇 阅读(155) 评论(0) 推荐(0)
摘要:Calculate a + b and output the sum in standard format -- that is, the digits must be separated into groups of three by commas (unless there are less t 阅读全文
posted @ 2018-06-07 19:01 赖兴宇 阅读(140) 评论(0) 推荐(0)
摘要:Given a sequence of positive numbers, a segment is defined to be a consecutive subsequence. For example, given the sequence {0.1, 0.2, 0.3, 0.4}, we h 阅读全文
posted @ 2018-06-05 23:22 赖兴宇 阅读(423) 评论(0) 推荐(0)
摘要:Suppose that all the keys in a binary tree are distinct positive integers. Given the preorder and inorder traversal sequences, you are supposed to out 阅读全文
posted @ 2018-06-05 22:47 赖兴宇 阅读(162) 评论(0) 推荐(0)
摘要:The string APPAPT contains two PAT's as substrings. The first one is formed by the 2nd, the 4th, and the 6th characters, and the second one is formed 阅读全文
posted @ 2018-06-05 21:19 赖兴宇 阅读(122) 评论(0) 推荐(0)
摘要:1124 Raffle for Weibo Followers (20)(20 分) John got a full mark on PAT. He was so happy that he decided to hold a raffle(抽奖) for his followers on Weib 阅读全文
posted @ 2018-06-05 21:06 赖兴宇 阅读(173) 评论(0) 推荐(0)
摘要:Behind the scenes in the computer's memory, color is always talked about as a series of 24 bits of information for each pixel. In an image, the color 阅读全文
posted @ 2018-06-05 20:39 赖兴宇 阅读(149) 评论(0) 推荐(0)
摘要:The ranklist of PAT is generated from the status list, which shows the scores of the submittions. This time you are supposed to generate the ranklist 阅读全文
posted @ 2018-06-05 20:22 赖兴宇 阅读(427) 评论(0) 推荐(0)
摘要:A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in moving a product from supplier to customer 阅读全文
posted @ 2018-06-05 12:59 赖兴宇 阅读(153) 评论(0) 推荐(0)
摘要:"Damn Single (单身狗)" is the Chinese nickname for someone who is being single. You are supposed to find those who are alone in a big party, so they can 阅读全文
posted @ 2018-06-05 01:36 赖兴宇 阅读(267) 评论(0) 推荐(0)
摘要:If you are a fan of Harry Potter, you would know the world of magic has its own currency system -- as Hagrid explained it to Harry, "Seventeen silver 阅读全文
posted @ 2018-06-05 00:44 赖兴宇 阅读(150) 评论(0) 推荐(0)
摘要:The task is really simple: given N exits on a highway which forms a simple cycle, you are supposed to tell the shortest distance between any pair of e 阅读全文
posted @ 2018-06-04 23:52 赖兴宇 阅读(197) 评论(0) 推荐(0)
摘要:1061 Dating (20)(20 分) Sherlock Holmes received a note with some strange strings: "Let's date! 3485djDkxh4hhGE 2984akDfkkkkggEdsb s&hgsfdk d&Hyscvnm". 阅读全文
posted @ 2018-06-04 23:13 赖兴宇 阅读(856) 评论(0) 推荐(0)
摘要:Being unique is so important to people on Mars that even their lottery is designed in a unique way. The rule of winning is simple: one bets on a numbe 阅读全文
posted @ 2018-06-04 14:52 赖兴宇 阅读(511) 评论(0) 推荐(0)
摘要:A reversible prime in any number system is a prime whose "reverse" in that number system is also a prime. For example in the decimal system 73 is a re 阅读全文
posted @ 2018-06-04 14:30 赖兴宇 阅读(159) 评论(0) 推荐(0)
摘要:People in Mars represent the colors in their computers in a similar way as the Earth people. That is, a color is represented by a 6-digit number, wher 阅读全文
posted @ 2018-06-04 00:36 赖兴宇 阅读(155) 评论(0) 推荐(0)
摘要:The highest building in our city has only one elevator. A request list is made up with N positive numbers. The numbers denote at which floors the elev 阅读全文
posted @ 2018-06-04 00:11 赖兴宇 阅读(161) 评论(0) 推荐(0)