![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
算法竞赛
文章平均质量分 52
收集汇总一些算法竞赛的题目
TOBEALISTENER
To Be A Listener
展开
-
Problem G: G. Interference Signal
Problem G: G. Interference SignalTime Limit: 2 Sec Memory Limit: 128 MBSubmit: 17 Solved: 16[Submit][Status][Web Board]DescriptionDr.Kong’s laboratory monitor some interference signals. The interf...原创 2018-05-20 18:58:43 · 212 阅读 · 0 评论 -
Problem F: F. Distribution
Problem F: F. DistributionTime Limit: 1 Sec Memory Limit: 128 MBSubmit: 10 Solved: 9[Submit][Status][Web Board]DescriptionOne day , Wang and Dong in the Dubai desert expedition, discovered an anci...原创 2018-05-20 18:56:49 · 178 阅读 · 0 评论 -
Problem B: B.最大岛屿
Problem B: B.最大岛屿 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 24 Solved: 16[Submit][Status][Web Board]Description 神秘的海洋,惊险的探险之路,打捞海底宝藏,激烈的海战,海盗劫富等等。加勒比海盗,你知道吧?杰克船长驾驶着自己的的战船黑珍珠1号要征服各个海岛的海盜,最后成为海盗...原创 2018-05-20 18:52:22 · 245 阅读 · 0 评论 -
Problem A: A.挑战密室
Problem A: A.挑战密室Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 53 Solved: 32[Submit][Status][Web Board]DescriptionR组织的特工Dr. Kong 为了寻找丢失的超体元素,不幸陷入WTO密室。Dr. Kong必须尽快找到解锁密码逃离,否则几分钟之后,WTO密室即将爆炸。 Dr. Kon...原创 2018-05-20 18:50:09 · 235 阅读 · 0 评论 -
Problem E: E.疫情控制
Problem E: E.疫情控制 Time Limit: 3 Sec Memory Limit: 128 MBSubmit: 6 Solved: 4[Submit][Status][Web Board]Description据某省水产部门通报,A市大面积范围水产养殖区爆发ADH氏菌疫情,导致大量鱼苗死亡,养殖户经济损失巨大。必须尽快控制疫情,使水产养殖秩序回归正常。此次ADH氏菌疫情传染范围...原创 2018-05-20 18:47:34 · 1149 阅读 · 2 评论 -
1011 World Cup Betting (20 分)
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 battles for the World Cup trophy in South Africa. Si...原创 2019-03-11 18:21:03 · 134 阅读 · 0 评论 -
1010 Radix (25 分)
Given a pair of positive integers, for example, 6 and 110, can this equation 6 = 110 be true? The answer is yes, if 6 is a decimal number and 110 is a binary number.Now for any pair of positive inte...转载 2019-03-11 18:15:59 · 147 阅读 · 0 评论 -
1009 Product of Polynomials (25 分)
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 occupies 2 lines, and each line contains the informa...原创 2019-01-27 18:29:14 · 128 阅读 · 0 评论 -
1008 Elevator (20 分)
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 elevator will stop, in specified order. It costs 6 sec...原创 2019-01-27 18:08:43 · 123 阅读 · 0 评论 -
1007 Maximum Subsequence Sum (25 分)
Given a sequence of K integers { N1, N2, ..., NK }. A continuous subsequence is defined to be { Ni, Ni+1, ..., Nj } where 1≤i≤j≤K. The Maximum Subsequence is the continuous subsequen...原创 2019-01-27 17:31:03 · 250 阅读 · 0 评论 -
1006 Sign In and Sign Out (25 分)
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. Given the records of signing in's and out's, you...原创 2019-01-24 22:44:43 · 159 阅读 · 0 评论 -
1005 Spell It Right (20 分)
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 Specification:Each input file contains one test case. Eac...原创 2019-01-24 22:21:52 · 116 阅读 · 0 评论 -
1004 Counting Leaves (30 分)
A family hierarchy is usually presented by a pedigree tree. Your job is to count those family members who have no child.Input Specification:Each input file contains one test case. Each case starts...原创 2019-01-24 18:42:20 · 258 阅读 · 0 评论 -
1003 Emergency (25 分)
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 roads. Amount of rescue teams in each city and the l...原创 2019-01-24 17:55:58 · 145 阅读 · 0 评论 -
1002 A+B for Polynomials
This time, you are supposed to find A+BA+BA+B where AAA and BBB are two polynomials.Input Specification:Each input file contains one test case. Each case occupies 2 lines, and each line contains t...原创 2019-01-24 15:58:32 · 121 阅读 · 0 评论 -
1001 A+B Format
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 than four digits).Input Specification:Each input ...原创 2019-01-24 15:05:45 · 180 阅读 · 0 评论 -
7-7 人以群分(25 分)
社交网络中我们给每个人定义了一个“活跃度”,现希望根据这个指标把人群分为两大类,即外向型(outgoing,即活跃度高的)和内向型(introverted,即活跃度低的)。要求两类人群的规模尽可能接近,而他们的总活跃度差距尽可能拉开。输入格式:输入第一行给出一个正整数N(2≤N≤105)。随后一行给出N个正整数,分别是每个人的活跃度,其间以空格分隔。题目保证这些数字以及它们的和都不会...原创 2018-07-19 17:28:54 · 1286 阅读 · 0 评论 -
7-6 排序(25 分)
给定N个(长整型范围内的)整数,要求输出从小到大排序后的结果。本题旨在测试各种不同的排序算法在各种数据情况下的表现。各组测试数据特点如下:数据1:只有1个元素; 数据2:11个不相同的整数,测试基本正确性; 数据3:103个随机整数; 数据4:104个随机整数; 数据5:105个随机整数; 数据6:105个顺序整数; 数据7:105个逆序整数; 数据8:105个基本有序的整数...原创 2018-07-19 17:25:25 · 1300 阅读 · 0 评论 -
7-4 抢红包(25 分)
没有人没抢过红包吧…… 这里给出N个人之间互相发红包、抢红包的记录,请你统计一下他们抢红包的收获。输入格式:输入第一行给出一个正整数N(≤104),即参与发红包和抢红包的总人数,则这些人从1到N编号。随后N行,第i行给出编号为i的人发红包的记录,格式如下:KN1P1⋯NKPK其中K(0≤K≤20)是发出去的红包个数,Ni是抢到红包的人的编号,P...原创 2018-07-19 17:24:12 · 1278 阅读 · 0 评论 -
7-3 部落(25 分)
在一个社区里,每个人都有自己的小圈子,还可能同时属于很多不同的朋友圈。我们认为朋友的朋友都算在一个部落里,于是要请你统计一下,在一个给定社区中,到底有多少个互不相交的部落?并且检查任意两个人是否属于同一个部落。输入格式:输入在第一行给出一个正整数N(≤104),是已知小圈子的个数。随后N行,每行按下列格式给出一个小圈子里的人:K P[1] P[2] ⋯ P[K]其中K是小圈子...原创 2018-07-19 17:23:14 · 2219 阅读 · 0 评论 -
PTA 7-2 朋友圈(25 分)
某学校有N个学生,形成M个俱乐部。每个俱乐部里的学生有着一定相似的兴趣爱好,形成一个朋友圈。一个学生可以同时属于若干个不同的俱乐部。根据“我的朋友的朋友也是我的朋友”这个推论可以得出,如果A和B是朋友,且B和C是朋友,则A和C也是朋友。请编写程序计算最大朋友圈中有多少人。输入格式:输入的第一行包含两个正整数N(≤30000)和M(≤1000),分别代表学校的学生总数和俱乐部的个数。后面的M...原创 2018-07-19 17:21:56 · 2495 阅读 · 0 评论 -
PTA 7-1 File Transfer
We have a network of computers and a list of bi-directional connections. Each of these connections allows a file transfer from one computer to another. Is it possible to send a file from any computer ...原创 2018-07-19 17:19:34 · 869 阅读 · 0 评论 -
PTA 简易连连看
本题要求实现一个简易连连看游戏模拟程序。给定一个2N×2N的方阵网格游戏盘面,每个格子中放置一些符号。这些符号一定是成对出现的,同一个符号可能不止一对。程序读入玩家给出的一对位置(x1,y1)、(x2,y2),判断这两个位置上的符号是否匹配。如果匹配成功,则将两个符号消为“*”并输出消去后的盘面;否则输出“Uh-oh”。若匹配错误达到3次,则输出“Game Over”并结束...原创 2018-04-11 15:44:20 · 816 阅读 · 0 评论 -
PTA 符号配对
请编写程序检查C语言源程序中下列符号是否配对:/*与*/、(与)、[与]、{与}。输入格式:输入为一个C语言源程序。当读到某一行中只有一个句点.和一个回车的时候,标志着输入结束。程序中需要检查配对的符号不超过100个。输出格式:首先,如果所有符号配对正确,则在第一行中输出YES,否则输出NO。然后在第二行中指出第一个不配对的符号:如果缺少左符号,则输出?-右符号;如果缺少右符号,则输出左符号-?。...原创 2018-04-11 15:32:18 · 669 阅读 · 0 评论 -
PTA 海盗分赃
P 个海盗偷了 D 颗钻石后来到公海分赃,一致同意如下分赃策略:首先,P 个海盗通过抽签决定 1 - P 的序号。然后由第 1 号海盗提出一个分配方案(方案应给出每个海盗分得的具体数量),如果能够得到包括 1 号在内的绝对多数(即大于半数)同意,则按照该分配方案执行,否则 1 号将被投入大海喂鲨鱼;而后依次类似地由第 2 号、第 3 号等等海盗提出方案,直到能够获得绝对多数同意的方案出现为止,或者...原创 2018-04-11 15:26:46 · 1207 阅读 · 0 评论 -
PTA 素因子分解
7-11 素因子分解(20 分)给定某个正整数 N,求其素因子分解结果,即给出其因式分解表达式 N=p1k1⋅p2k2⋯pmkm。输入格式:输入long int范围内的正整数 N。输出格式:按给定格式输出N的素因式分解表达式,即 N=p1^k1*p2^k2*…*pm^km,其中pi为素因子并要求由小到大输出,指数ki为pi的个数;当ki为1即因...原创 2018-04-11 15:00:39 · 2153 阅读 · 0 评论 -
[leetcode每日一题]530. 二叉搜索树的最小绝对差
给你一棵所有节点为非负值的二叉搜索树,请你计算树中任意两节点的差的绝对值的最小值。输入: 1 \ 3 / 2输出:1解释:最小绝对差为 1,其中 2 和 1 的差的绝对值为 1(或者 2 和 3)。提示:树中至少有 2 个节点。本题与 783 https://leetcode-cn.com/problems/minimum-distance-between-bst-nodes/ 相同解题思路:题目中给的二叉搜索树这个信息很重要,当二叉树原创 2020-10-12 02:19:49 · 132 阅读 · 0 评论 -
29. 两数相除
给定两个整数,被除数 dividend 和除数 divisor。将两数相除,要求不使用乘法、除法和 mod 运算符。返回被除数 *dividend *除以除数 *divisor *得到的商。整数除法的结果应当截去*(truncate)*其小数部分,例如:truncate(8.345) = 8 以及 truncate(-2.7335) = -2示例 1:输入: dividend = 10, divisor = 3输出: 3解释: 10/3 = truncate(3.33333…) = trunc原创 2020-06-07 02:20:41 · 340 阅读 · 0 评论 -
leetcode 练习题 --18. 四数之和
题目描述:给定一个包含 n 个整数的数组 nums 和一个目标值 target,判断 nums 中是否存在四个元素 a,b,c 和 d ,使得 a + b + c + d 的值与 target 相等?找出所有满足条件且不重复的四元组。注意:答案中不可以包含重复的四元组。示例:给定数组 nums = [1, 0, -1, 0, -2, 2],和 target = 0。满足要...原创 2019-01-21 19:27:51 · 160 阅读 · 0 评论 -
leetcode 练习题 --17. 电话号码的字母组合
题目描述:给定一个仅包含数字 2-9 的字符串,返回所有它能表示的字母组合。给出数字到字母的映射如下(与电话按键相同)。注意 1 不对应任何字母。示例:输入:"23"输出:["ad", "ae", "af", "bd", "be", "bf", "cd", "ce", "cf"].原创 2019-01-21 19:26:31 · 174 阅读 · 0 评论 -
leetcode 练习题 --16. 最接近的三数之和
题目描述:给定一个包括 n 个整数的数组 nums 和 一个目标值 target。找出 nums 中的三个整数,使得它们的和与 target 最接近。返回这三个数的和。假定每组输入只存在唯一答案。例如,给定数组 nums = [-1,2,1,-4], 和 target = 1.与 target 最接近的三个数的和为 2. (-1 + 2 + 1 = 2).代码如下:int...原创 2019-01-21 19:25:17 · 148 阅读 · 0 评论 -
leetcode 练习题 --15. 三数之和
题目描述:给定一个包含 n 个整数的数组 nums,判断 nums 中是否存在三个元素 a,b,c ,使得 a + b + c = 0 ?找出所有满足条件且不重复的三元组。注意:答案中不可以包含重复的三元组。例如, 给定数组 nums = [-1, 0, 1, 2, -1, -4],满足要求的三元组集合为:[ [-1, 0, 1], [-1, -1, 2]]代码...原创 2019-01-21 19:23:33 · 128 阅读 · 0 评论 -
leetcode 练习题 -- 14. 最长公共前缀
题目描述:编写一个函数来查找字符串数组中的最长公共前缀。如果不存在公共前缀,返回空字符串 ""。示例 1:输入: ["flower","flow","flight"]输出: "fl"示例 2:输入: ["dog","racecar","car"]输出: ""解释: 输入不存在公共前缀。代码原创 2019-01-21 19:22:08 · 146 阅读 · 0 评论 -
leetcode 练习题 -- 13. 罗马数字转整数
题目描述:罗马数字包含以下七种字符: I, V, X, L,C,D 和 M。字符 数值I 1V 5X 10L 50C 100D 500M 1000例如, 罗马数字 2 写做 II ,即为...原创 2019-01-21 19:20:33 · 188 阅读 · 0 评论 -
leetcode 练习题 -- 12. 整数转罗马数字
题目描述:罗马数字包含以下七种字符: I, V, X, L,C,D 和 M。字符 数值I 1V 5X 10L 50C 100D 500M 1000例如, 罗马数字 2 写做 II ,即为...原创 2019-01-21 19:18:12 · 143 阅读 · 0 评论 -
leetcode 练习题 -- 11. 盛最多水的容器
题目描述:给定 n 个非负整数 a1,a2,...,an,每个数代表坐标中的一个点 (i, ai) 。在坐标内画 n 条垂直线,垂直线 i 的两个端点分别为 (i, ai) 和 (i, 0)。找出其中的两条线,使得它们与 x 轴共同构成的容器可以容纳最多的水。说明:你不能倾斜容器,且 n 的值至少为 2。图中垂直线代表输入数组 [1,8,6,2,5,4,8,3,7]。在此情况下,容...原创 2019-01-21 19:16:09 · 183 阅读 · 0 评论 -
leetcode 练习题 -- 10. 正则表达式匹配
题目描述:给定一个字符串 (s) 和一个字符模式 (p)。实现支持 '.' 和 '*' 的正则表达式匹配。'.' 匹配任意单个字符。'*' 匹配零个或多个前面的元素。匹配应该覆盖整个字符串 (s) ,而不是部分字符串。说明:s 可能为空,且只包含从 a-z 的小写字母。 p 可能为空,且只包含从 a-z 的小写字母,以及字符 . 和 *。示例 1:输入:s =...原创 2019-01-21 19:13:40 · 163 阅读 · 0 评论 -
leetcode 练习题 -- 1. 两数之和
示例:给定一个整数数组 nums 和一个目标值 target,请你在该数组中找出和为目标值的那 两个 整数,并返回他们的数组下标。你可以假设每种输入只会对应一个答案。但是,你不能重复利用这个数组中同样的元素。示例:给定 nums = [2, 7, 11, 15], target = 9因为 nums[0] + nums[1] = 2 + 7 = 9所以返回 [0, 1]...原创 2019-01-21 19:11:27 · 141 阅读 · 0 评论 -
leetcode 练习题 -- 9. Palindrome Number
描述:Determine whether an integer is a palindrome. Do this without extra space.click to show spoilers.Some hints:Could negative integers be palindromes? (ie, -1)If you are thinking o原创 2018-01-17 17:47:28 · 166 阅读 · 0 评论 -
leetcode 练习题 -- 8. String to Integer (atoi)
描述:Implement atoi to convert a string to an integer.Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possible i原创 2018-01-17 16:46:47 · 206 阅读 · 0 评论