自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(57)
  • 收藏
  • 关注

原创 1023 Have Fun with Numbers (20 分)

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 246913578, which happens to be another 9-digit number con...

2019-01-22 21:17:55 227

原创 1134 Vertex Cover (25 分)

A vertex cover of a graph is a set of vertices such that each edge of the graph is incident to at least one vertex of the set. Now given a graph with several vertex sets, you are supposed to tell if e...

2019-01-22 21:16:33 165

原创 1133 Splitting A Linked List (25 分)

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 the values in [0, K] appear before all those grea...

2019-01-22 21:15:43 143

原创 1027 Colors in Mars (20 分)

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, where the first 2 digits are for Red, the middle 2 dig...

2019-01-22 16:13:19 108

原创 1043 Is It a Binary Search Tree (25 分)

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 with keys less than the node's key. The right su...

2019-01-21 15:03:17 204

原创 1120 Friend Numbers (20 分)

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 friend numbers since 1+2+3 = 5+1 = 6, and 6 is their ...

2019-01-21 15:01:45 75

原创 1099 Build A Binary Search Tree (30 分)

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 with keys less than the node's key. The right su...

2019-01-19 21:44:40 231

原创 1025 PAT Ranking (25 分)

Programming Ability Test (PAT) is organized by the College of Computer Science and Technology of Zhejiang University. Each test is supposed to run simultaneously in several places, and the ranklists w...

2019-01-19 21:43:16 157 4

原创 1119 Pre- and Post-order Traversals (30 分)

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 inorder traversal sequences, or preorder and inorder ...

2019-01-19 16:46:08 212

原创 1020 Tree Traversals (25 分)

Suppose that all the keys in a binary tree are distinct positive integers. Given the postorder and inorder traversal sequences, you are supposed to output the level order traversal sequence of the cor...

2019-01-19 11:13:40 261

原创 1127 ZigZagging on a Tree (30 分)

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 inorder traversal sequences. And it is a simple stand...

2019-01-19 10:51:17 595

原创 1138 Postorder Traversal (25 分)

Suppose that all the keys in a binary tree are distinct positive integers. Given the preorder and inorder traversal sequences, you are supposed to output the first number of the postorder traversal se...

2019-01-19 10:07:18 192

原创 1115 Counting Nodes in a BST (30 分)

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 with keys less than or equal to the node's key. ...

2019-01-19 10:06:13 205

原创 1141 PAT Ranking of Institutions (25 分)

After each PAT, the PAT Center will announce the ranking of institutions based on their students' performances. Now you are asked to generate the ranklist.Input Specification:Each input file conta...

2019-01-18 16:33:11 205

原创 1143 Lowest Common Ancestor (30 分)

The lowest common ancestor (LCA) of two nodes U and V in a tree is the deepest node that has both U and V as descendants.A binary search tree (BST) is recursively defined as a binary tree which has ...

2019-01-18 16:11:11 216

原创 1151 LCA in a Binary Tree (30 分)

The lowest common ancestor (LCA) of two nodes U and V in a tree is the deepest node that has both U and V as descendants.Given any two nodes in a binary tree, you are supposed to find their LCA.In...

2019-01-18 16:10:15 148

原创 1155 Heap Paths (30 分)

In computer science, a heap is a specialized tree-based data structure that satisfies the heap property: if P is a parent node of C, then the key (the value) of P is either greater than or equal to (i...

2019-01-17 14:58:42 104

原创 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-17 11:02:08 248

原创 1048 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-17 10:41:40 82

原创 1041 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 o...

2019-01-17 09:58:40 88

原创 1050 String Subtraction (20 分)

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 simply to calculate S​1​​−S​2​​ for any given s...

2019-01-16 21:35:39 62

原创 1140 Look-and-say Sequence (20 分)

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)st number is a kind of description of the nth n...

2019-01-16 20:51:07 88

原创 1147 Heaps (30 分)

In computer science, a heap is a specialized tree-based data structure that satisfies the heap property: if P is a parent node of C, then the key (the value) of P is either greater than or equal to (i...

2019-01-16 15:39:37 57

原创 1092 To Buy or Not to Buy (20 分)

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 beads. However the owner of the shop would only sel...

2019-01-16 10:59:57 70

原创 1145 Hashing - Average Search Time (25 分)

The task of this problem is simple: insert a sequence of distinct positive integers into a hash table first. Then try to find another sequence of integer keys from the table and output the average sea...

2019-01-16 10:48:34 48

原创 1144 The Missing Number (20 分)

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 one test case. For each case, the first line giv...

2019-01-16 10:44:56 46

原创 1146 Topological Order (25 分)

This is a problem given in the Graduate Entrance Exam in 2018: Which of the following is NOT a topological order obtained from the given directed graph? Now you are supposed to write a program to test...

2019-01-16 10:42:50 131

原创 1069 微博转发抽奖 (20 分)

小明 PAT 考了满分,高兴之余决定发起微博转发抽奖活动,从转发的网友中按顺序每隔 N 个人就发出一个红包。请你编写程序帮助他确定中奖名单。输入格式:输入第一行给出三个正整数 M(≤ 1000)、N 和 S,分别是转发的总量、小明决定的中奖间隔、以及第一位中奖者的序号(编号从 1 开始)。随后 M 行,顺序给出转发微博的网友的昵称(不超过 20 个字符、不包含空格回车的非空字符串)。注...

2019-01-15 21:34:21 62

原创 1078 Hashing (25 分)

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. The hash function is defined to be H(key)=key%TSiz...

2019-01-15 20:55:27 168

原创 1036 Boys vs Girls (25 分)

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.Input Specification:Each input file contains one t...

2019-01-15 10:03:46 60

原创 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-15 09:42:17 109

原创 乙级--1083 是否存在相等的差 (20 分)

给定 N 张卡片,正面分别写上 1、2、……、N,然后全部翻面,洗牌,在背面分别写上 1、2、……、N。将每张牌的正反两面数字相减(大减小),得到 N 个非负差值,其中是否存在相等的差?输入格式:输入第一行给出一个正整数 N(2 ≤ N ≤ 10 000),随后一行给出 1 到 N 的一个洗牌后的排列,第 i 个数表示正面写了 i 的那张卡片背面的数字。输出格式:按照“差值 重复次...

2019-01-15 08:46:03 65

原创 乙级--1088 三人行 (20 分)

子曰:“三人行,必有我师焉。择其善者而从之,其不善者而改之。”本题给定甲、乙、丙三个人的能力值关系为:甲的能力值确定是 2 位正整数;把甲的能力值的 2 个数字调换位置就是乙的能力值;甲乙两人能力差是丙的能力值的 X 倍;乙的能力值是丙的 Y 倍。请你指出谁比你强应“从之”,谁比你弱应“改之”。输入格式:输入在一行中给出三个数,依次为:M(你自己的能力值)、X 和 Y。三个数字均为不超...

2019-01-13 22:18:51 77

原创 乙级 1087 有多少不同的值 (20 分)

当自然数 n 依次取 1、2、3、……、N 时,算式 ⌊n/2⌋+⌊n/3⌋+⌊n/5⌋ 有多少个不同的值?(注:⌊x⌋ 为取整函数,表示不超过 x 的最大自然数,即 x 的整数部分。)输入格式:输入给出一个正整数 N(2≤N≤10​4​​)。输出格式:在一行中输出题面中算式取到的不同值的个数。输入样例:2017输出样例:1480  #include...

2019-01-13 21:53:58 64

原创 1154 Vertex Coloring (25 分)

A proper vertex coloring is a labeling of the graph's vertices with colors such that no two vertices sharing the same edge have the same color. A coloring using at most k colors is called a (proper) k...

2019-01-13 21:06:01 139

原创 乙级--1095 解码PAT准考证 (25 分)

PAT 准考证号由 4 部分组成:第 1 位是级别,即 T 代表顶级;A 代表甲级;B 代表乙级; 第 2~4 位是考场编号,范围从 101 到 999; 第 5~10 位是考试日期,格式为年、月、日顺次各占 2 位; 最后 11~13 位是考生编号,范围从 000 到 999。现给定一系列考生的准考证号和他们的成绩,请你按照要求输出各种统计信息。输入格式:输入首先在一行中给出...

2019-01-13 21:01:57 101

原创 乙级--1094 谷歌的招聘 (20 分)

同甲级1152. 2004 年 7 月,谷歌在硅谷的 101 号公路边竖立了一块巨大的广告牌(如下图)用于招聘。内容超级简单,就是一个以 .com 结尾的网址,而前面的网址是一个 10 位素数,这个素数是自然常数 e 中最早出现的 10 位连续数字。能找出这个素数的人,就可以通过访问谷歌的这个网站进入招聘流程的下一步。自然常数 e 是一个著名的超越数,前面若干位写出来是这样的:e = ...

2019-01-12 16:13:08 510

原创 乙级--1093 字符串A+B

给定两个字符串 A 和 B,本题要求你输出 A+B,即两个字符串的并集。要求先输出 A,再输出 B,但重复的字符必须被剔除。输入格式:输入在两行中分别给出 A 和 B,均为长度不超过 10​6​​的、由可见 ASCII 字符 (即码值为32~126)和空格组成的、由回车标识结束的非空字符串。输出格式:在一行中输出题面要求的 A 和 B 的和。输入样例:This is a ...

2019-01-12 15:23:33 91

原创 乙级--1092 最好吃的月饼 (20 分)

月饼是久负盛名的中国传统糕点之一,自唐朝以来,已经发展出几百品种。若想评比出一种“最好吃”的月饼,那势必在吃货界引发一场腥风血雨…… 在这里我们用数字说话,给出全国各地各种月饼的销量,要求你从中找出销量冠军,认定为最好吃的月饼。输入格式:输入首先给出两个正整数 N(≤1000)和 M(≤100),分别为月饼的种类数(于是默认月饼种类从 1 到 N 编号)和参与统计的城市数量。接...

2019-01-12 15:08:10 78

原创 乙级--1091 N-自守数

如果某个数 K 的平方乘以 N 以后,结果的末尾几位数等于 K,那么就称这个数为“N-自守数”。例如 3×92​2​​=25392,而 25392 的末尾两位正好是 92,所以 92 是一个 3-自守数。本题就请你编写程序判断一个给定的数字是否关于某个 N 是 N-自守数。输入格式:输入在第一行中给出正整数 M(≤20),随后一行给出 M 个待检测的、不超过 1000 的正整数。输...

2019-01-12 14:35:41 111 1

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除