水题
julia7_
keep coding
展开
-
B1006 换个格式输出整数 (15 分)(水题)
让我们用字母B来表示“百”、字母S表示“十”,用12...n来表示不为零的个位数字n(<10),换个格式来输出任一个不超过 3 位的正整数。例如234应该被输出为BBSSS1234,因为它有 2 个“百”、3 个“十”、以及个位的 4。输入格式:每个测试输入包含 1 个测试用例,给出正整数n(<1000)。输出格式:每个测试用例的输出占一行,用规定...原创 2019-01-13 12:31:20 · 167 阅读 · 0 评论 -
A1041 Be Unique (20 分)(哈希)(水题)
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 number chosen from [1,10^4]. The first one who bets ...原创 2019-01-24 13:44:36 · 168 阅读 · 0 评论 -
A1050 String Subtraction (20 分)(哈希)(水题)
Given two stringsS1andS2,S=S1−S2is defined to be the remaining string after taking all the characters inS2fromS1. Your task is simply to calculateS1−S2for any given s...原创 2019-01-24 17:45:33 · 183 阅读 · 0 评论 -
A1048 Find Coins (25 分)(水题)
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 could accept all kinds of coins as payments. However,...原创 2019-01-24 22:22:00 · 244 阅读 · 0 评论 -
B1023 组个最小数 (20 分)(贪心)(水题)
给定数字 0-9 各若干个。你可以以任意顺序排列这些数字,但必须全部使用。目标是使得最后得到的数尽可能小(注意 0 不能做首位)。例如:给定两个 0,两个 1,三个 5,一个 8,我们得到的最小的数就是 10015558。现给定数字,请编写程序输出能够组成的最小的数。输入格式:输入在一行中给出 10 个非负整数,顺序表示我们拥有数字 0、数字 1、……数字 9 的个数。整数间用一个空格...原创 2019-01-17 10:42:14 · 128 阅读 · 0 评论 -
B1020 月饼 (25 分)(贪心)(水题)
月饼是中国人在中秋佳节时吃的一种传统食品,不同地区有许多不同风味的月饼。现给定所有种类月饼的库存量、总售价、以及市场的最大需求量,请你计算可以获得的最大收益是多少。注意:销售时允许取出一部分库存。样例给出的情形是这样的:假如我们有 3 种月饼,其库存量分别为 18、15、10 万吨,总售价分别为 75、72、45 亿元。如果市场的最大需求量只有 20 万吨,那么我们最大收益策略应该是卖出全部 ...原创 2019-01-16 22:15:58 · 1029 阅读 · 1 评论 -
B1041 考试座位号(水题)
每个 PAT 考生在参加考试时都会被分配两个座位号,一个是试机座位,一个是考试座位。正常情况下,考生在入场时先得到试机座位号码,入座进入试机状态后,系统会显示该考生的考试座位号码,考试时考生需要换到考试座位就座。但有些考生迟到了,试机已经结束,他们只能拿着领到的试机座位号码求助于你,从后台查出他们的考试座位号码。输入格式:输入第一行给出一个正整数N(≤1000),随后N行,每行给出一...原创 2019-01-11 20:54:04 · 202 阅读 · 1 评论 -
B1004 成绩排名(水题)
读入n(>0)名学生的姓名、学号、成绩,分别输出成绩最高和成绩最低学生的姓名和学号。输入格式:每个测试输入包含 1 个测试用例,格式为第 1 行:正整数 n第 2 行:第 1 个学生的姓名 学号 成绩第 3 行:第 2 个学生的姓名 学号 成绩 ... ... ...第 n+1 行:第 n 个学生的姓名 学号 成绩其中姓名和学号均为不超过 10 个字符的字符串...原创 2019-01-11 21:18:03 · 147 阅读 · 1 评论 -
B1028 人口普查(水题)
某城镇进行人口普查,得到了全体居民的生日。现请你写个程序,找出镇上最年长和最年轻的人。这里确保每个输入的日期都是合法的,但不一定是合理的——假设已知镇上没有超过 200 岁的老人,而今天是 2014 年 9 月 6 日,所以超过 200 岁的生日和未出生的生日都是不合理的,应该被过滤掉。输入格式:输入在第一行给出正整数N,取值在(0,105];随后N行,每行给出 1 个人的...原创 2019-01-11 22:30:37 · 211 阅读 · 0 评论 -
A1011 World Cup Betting(水题)
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-01-11 23:17:53 · 147 阅读 · 0 评论 -
A1006 Sign In and Sign Out(水题)
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-12 14:10:47 · 191 阅读 · 0 评论 -
A1037 Magic Coupon (25 分)(贪心)(水题)
The magic shop in Mars is offering some magic coupons. Each coupon has an integerNprinted on it, meaning that when you use this coupon with a product, you may getNtimes the value of that product b...原创 2019-01-25 12:29:47 · 158 阅读 · 0 评论 -
剑指Offer(四十三):左旋转字符串(水题)
题目汇编语言中有一种移位指令叫做循环左移(ROL),现在有个简单的任务,就是用字符串模拟这个指令的运算结果。对于一个给定的字符序列S,请你把其循环左移K位后的序列输出。例如,字符序列S=”abcXYZdef”,要求输出循环左移3位后的结果,即“XYZdefabc”。AC代码:不用真的左移,从第n位输出,再从0位输出class Solution {public: stri...原创 2019-03-11 19:54:16 · 150 阅读 · 0 评论 -
剑指Offer(四十九):把字符串转换成整数(水题)
题目将一个字符串转换成一个整数,要求不能使用字符串转换整数的库函数。 数值为0或者字符串不是一个合法的数值则返回0。输入描述:输入一个字符串,包括数字字母符号,可以为空输出描述:如果是合法的数值表达则返回该数字,否则返回0示例1输入+21474836471a33输出21474836470AC代码:class Solution {...原创 2019-03-11 20:22:26 · 222 阅读 · 1 评论 -
B1013 数素数 (20 分)(水题)
令Pi表示第i个素数。现任给两个正整数M≤N≤10^4,请输出PM到PN的所有素数。输入格式:输入在一行中给出M和N,其间以空格分隔。输出格式:输出从PM到PN的所有素数,每 10 个数字占 1 行,其间以空格分隔,但行末不得有多余空格。输入样例:5 27输出样例:11 13 17 19 23 ...原创 2019-01-28 18:24:45 · 339 阅读 · 0 评论 -
B1042 字符统计 (20 分)(水题)
请编写程序,找出一段给定文字中出现最频繁的那个英文字母。输入格式:输入在一行中给出一个长度不超过 1000 的字符串。字符串由 ASCII 码表中任意可见字符及空格组成,至少包含 1 个英文字母,以回车结束(回车不算在内)。输出格式:在一行中输出出现频率最高的那个英文字母及其出现次数,其间以空格分隔。如果有并列,则输出按字母序最小的那个字母。统计时不区分大小写,输出小写字母。输...原创 2019-01-23 13:31:29 · 517 阅读 · 0 评论 -
B1038 统计同成绩学生 (20 分)(哈希)(水题)
本题要求读入N名学生的成绩,将获得某一给定分数的学生人数输出。输入格式:输入在第 1 行给出不超过105的正整数N,即学生总人数。随后一行给出N名学生的百分制整数成绩,中间以空格分隔。最后一行给出要查询的分数个数K(不超过N的正整数),随后是K个分数,中间以空格分隔。输出格式:在一行中按查询顺序给出得分等于指定分数的学生人数,中间以空格分隔,但行末不得...原创 2019-01-22 13:22:22 · 115 阅读 · 0 评论 -
A1004 Counting Leaves (30 分)(类似题)(DFS)
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-02-24 18:09:28 · 145 阅读 · 0 评论 -
A1019 General Palindromic Number(一般回文数)(20 分)(水题)
A number that will be the same when it is written forwards or backwards is known as aPalindromic Number. For example, 1234321 is a palindromic number. All single digit numbers are palindromic numbers...原创 2019-01-12 23:12:55 · 507 阅读 · 0 评论 -
B1037 在霍格沃茨找零钱 (20 分)(水题)
如果你是哈利·波特迷,你会知道魔法世界有它自己的货币系统 —— 就如海格告诉哈利的:“十七个银西可(Sickle)兑一个加隆(Galleon),二十九个纳特(Knut)兑一个西可”现在,给定哈利应付的价钱P和他实付的钱A,你的任务是写一个程序来计算他应该被找的零钱。1 galleon = 17 sickle1 sickle = 29 knut输入格式:输入在 1 行...原创 2019-01-12 21:54:41 · 264 阅读 · 0 评论 -
B1021 个位数统计 (15 分)(水题)
给定一个k位整数N=dk−110k−1+⋯+d1101+d0(0≤di≤9,i=0,⋯,k−1,dk−1>0),请编写程序统计每种不同的个位数字出现的次数。例如:给定N=100311,则有 2 个 0,3 个 1,和 1 个 3。输入格式:每个输入包含 1 个测试用例,即一个不超过 1000 位的正整数N。输出格式:对...原创 2019-01-13 12:42:13 · 176 阅读 · 0 评论 -
B1031 查验身份证 (15 分)(水题)
一个合法的身份证号码由17位地区、日期编号和顺序编号 加 1位校验码组成。校验码的计算规则如下:首先对前17位数字加权求和,权重分配为:{7,9,10,5, 8, 4, 2,1,6,3,7,9,10,5,8,4,2};然后将计算的和对11取模得到值Z;最后按照以下关系对应Z值与校验码M的值:Z:0 1 2 3 4 5 6 7 8 9 10M:1 0 X 9 8 7 6 5 4 ...原创 2019-01-13 13:06:23 · 213 阅读 · 0 评论 -
B1014 / A1061 福尔摩斯的约会 (20 分)(水题)
大侦探福尔摩斯接到一张奇怪的字条:我们约会吧! 3485djDkxh4hhGE 2984akDfkkkkggEdsb s&hgsfdk d&Hyscvnm。大侦探很快就明白了,字条上奇怪的乱码实际上就是约会的时间星期四 14:04,因为前面两字符串中第 1 对相同的大写英文字母(大小写有区分)是第 4 个字母D,代表星期四;第 2 对相同的字符是E,那是第 5 个...原创 2019-01-13 19:40:59 · 197 阅读 · 0 评论 -
B1036 跟奥巴马一起编程(水题)
美国总统奥巴马不仅呼吁所有人都学习编程,甚至以身作则编写代码,成为美国历史上首位编写计算机代码的总统。2014 年底,为庆祝“计算机科学教育周”正式启动,奥巴马编写了很简单的计算机代码:在屏幕上画一个正方形。现在你也跟他一起画吧!输入格式:输入在一行中给出正方形边长N(3≤N≤20)和组成正方形边的某种字符 C,间隔一个空格。输出格式:输出由给定字符 C 画出的正方形。但是注意到...原创 2019-01-12 18:39:19 · 139 阅读 · 0 评论 -
A1001 A+B Format (20 分)(水题)
Calculatea+band 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-13 23:35:51 · 177 阅读 · 0 评论 -
A1005 Spell It Right (20 分)(水题)
Given a non-negative integerN, your task is to compute the sum of all the digits ofN, and output every digit of the sum in English.Input Specification:Each input file contains one test case. Eac...原创 2019-01-13 23:53:58 · 151 阅读 · 0 评论 -
A1054 The Dominant Color (20 分)(水题)(map)
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 with the largest proportional area is called the d...原创 2019-02-19 12:50:00 · 122 阅读 · 0 评论 -
A1028 List Sorting (25 分)(按照三种排序规则排序)(水题)
Excel can sort records according to any column. Now you are supposed to imitate this function.Input Specification:Each input file contains one test case. For each case, the first line contains two...原创 2019-01-20 13:16:09 · 196 阅读 · 0 评论 -
A1083 List Grades (25 分)(水题)
Given a list ofNstudent records with name, ID and grade. You are supposed to sort the records with respect to the grade in non-increasing order, and output those student records of which the grades ...原创 2019-01-20 16:36:13 · 293 阅读 · 2 评论 -
B1001 害死人不偿命的(3n+1)猜想 (15 分)(水题)
卡拉兹(Callatz)猜想:对任何一个正整数n,如果它是偶数,那么把它砍掉一半;如果它是奇数,那么把(3n+1)砍掉一半。这样一直反复砍下去,最后一定在某一步得到n=1。卡拉兹在 1950 年的世界数学家大会上公布了这个猜想,传说当时耶鲁大学师生齐动员,拼命想证明这个貌似很傻很天真的命题,结果闹得学生们无心学业,一心只证(3n+1),以至于有人说这是一个阴谋,卡拉兹是在蓄意延缓美国...原创 2019-01-24 17:50:15 · 164 阅读 · 0 评论 -
1086 Tree Traversals Again (25 分)(前序+中序求后序)(水题)
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 keys numbered from 1 to 6) is traversed, the stac...原创 2019-02-23 16:00:23 · 303 阅读 · 0 评论 -
B1032 挖掘机技术哪家强(水题)
为了用事实说明挖掘机技术到底哪家强,PAT 组织了一场挖掘机技能大赛。现请你根据比赛结果统计出技术最强的那个学校。输入格式:输入在第 1 行给出不超过105的正整数N,即参赛人数。随后N行,每行给出一位参赛者的信息和成绩,包括其所代表的学校的编号(从 1 开始连续编号)、及其比赛成绩(百分制),中间以空格分隔。输出格式:在一行中给出总得分最高的学校的编号、及其总分,...原创 2019-01-11 22:56:33 · 153 阅读 · 0 评论 -
A1106 Lowest Price in Supply Chain (25 分)(与A1090相同)
A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in moving a product from supplier to customer.Starting from one root supplier, everyone on th...原创 2019-02-24 17:16:33 · 141 阅读 · 0 评论 -
A1015 Reversible Primes (20 分)(水题)
Areversible primein 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 reversible prime because its reverse 37 is also a pr...原创 2019-01-30 12:06:04 · 231 阅读 · 0 评论
分享