自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 A1097 Deduplication on a Linked List (25分)【C语言】

A1097 Deduplication on a Linked List (25分)【C语言】原题链接题目描述: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 value K, only the first node of which the value o

2020-07-20 11:52:01 141

原创 A1052 Linked List Sorting (25分)【C语言】

A1052 Linked List Sorting (25分)【C语言】原题链接题目描述: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 and a Next pointer to the next structure. Now given a link

2020-07-20 11:32:17 215

原创 B1025/A1074 反转链表 (25分)【C语言】

B1025/A1074 反转链表 (25分)【C语言】原题链接题目描述:给定一个常数 K 以及一个单链表 L,请编写程序将 L 中每 K 个结点反转。例如:给定 L 为 1→2→3→4→5→6,K 为 3,则输出应该为 3→2→1→6→5→4;如果 K 为 4,则输出应该为 4→3→2→1→5→6,即最后不到 K 个元素不反转。输入格式:每个输入包含 1 个测试用例。每个测试用例第 1 行给出第 1 个结点的地址、结点总个数正整数 N (≤10​5​​ )、以及正整数 K (≤N),即要求反转的子

2020-07-19 15:19:44 229

原创 A1032 Sharing (25分)【C语言】

A1032 Sharing (25分)【C语言】原题链接查找两个静态链表第一个共同地址题目描述: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 sublist if they share the same suffix. For example, loa

2020-07-19 14:45:32 151

原创 A1056 Mice and Rice (25分)【C语言】

A1056 Mice and Rice (25分)【C语言】原题链接题目描述: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 map. The goal of each mouse is to eat as much rice as possible i

2020-07-18 18:26:30 134

原创 A1051 Pop Sequence (25分)【C语言】

A1051 Pop Sequence (25分)【C语言】原题链接模拟真实入栈、出栈来判断题中所给出栈序列是否正确题目描述: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 sequence of numbers is a possible pop seque

2020-07-18 18:04:22 198

原创 A1024 Palindromic Number (25分)【C语言】

A1024 Palindromic Number (25分)【C语言】原题链接题目描述: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. All single digit numbers are palindromic numbers.Non-pal

2020-07-17 15:27:54 157

原创 A1023 Have Fun with Numbers (20分)【C语言】

A1023 Have Fun with Numbers (20分)【C语言】原题链接题目描述: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 consistin

2020-07-17 15:08:40 192

原创 B1017 A除以B (20分)【C语言】

B1017 A除以B (20分)【C语言】原题链接大整数除法题目描述:本题要求计算 A/B,其中 A 是不超过 1000 位的正整数,B 是 1 位正整数。你需要输出商数 Q 和余数 R,使得 A=B×Q+R 成立。输入格式:输入在一行中依次给出 A 和 B,中间以 1 空格分隔。输出格式:在一行中依次输出 Q 和 R,中间以 1 空格分隔。输入样例:123456789050987654321 7输出样例:17636684150141093474 3实现代码:#inclu

2020-07-16 16:10:40 131

原创 A1059 Prime Factors (25分)【C语言】

A1059 Prime Factors (25分)【C语言】原题链接构建素数表,通过遍历来找出N的全部质因子题目描述:​​输入样例:97532468输出样例:97532468=2^211171011291实现代码:#include <cstdio>#include <cmath>const int maxn = 100010;int prime[maxn], pNum=0; //素数表和素数个数 bool is_Prime(int n){ //判

2020-07-14 16:43:29 159

原创 A1096 Consecutive Factors (20分)【C语言】

A1096 Consecutive Factors (20分)【C语言】原题链接分解因子,找出能够整除的最长连续数字相乘,采用实时更新的方法题目描述:Among all the factors of a positive integer N, there may exist several consecutive numbers. For example, 630 can be factored as 3×5×6×7, where 5, 6, and 7 are the three consecut

2020-07-14 16:17:48 401 1

原创 A1078 Hashing (25分)【C语言】

A1078 Hashing (25分)【C语言】原题链接题目描述: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%TSize where TSize is the

2020-07-10 19:09:16 224

原创 A1015 Reversible Primes (20分)【C语言】

A1015 Reversible Primes (20分)【C语言】原题链接题目描述: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 reversible prime because its reverse 37 is also a prime.Now g

2020-07-09 18:42:52 136

原创 B1013 数素数 (20分)【C语言】

B1013 数素数 (20分)【C语言】原题链接题目描述:令 P​i​​ 表示第 i 个素数。现任给两个正整数 M≤N≤10 ​4​​ ,请输出 P​M​​ 到 P​N​​ 的所有素数。输入格式:输入在一行中给出 M 和 N,其间以空格分隔。输出格式:...

2020-07-09 18:28:45 144

原创 B1034/A1088 有理数四则运算 (20分)【C语言】

B1034/A1088 有理数四则运算 (20分)【C语言】原题链接分数的四则运算,最基本的模板。题目描述:本题要求编写程序,计算 2 个有理数的和、差、积、商。输入格式:输入在一行中按照 a1/b1 a2/b2 的格式给出两个分数形式的有理数,其中分子和分母全是整型范围内的整数,负号只可能出现在分子前,分母不为 0。输出格式:分别在 4 行中按照 有理数1 运算符 有理数2 = 结果 的格式顺序输出 2 个有理数的和、差、积、商。注意输出的每个有理数必须是该有理数的最简形式 k a/b,其

2020-07-08 16:22:40 273

原创 A1081 Rational Sum (20分)【C语言】

A1081 Rational Sum (20分)【C语言】原题链接分数加法(按晴神的套路)题目描述:Given N rational numbers in the form numerator/denominator, you are supposed to calculate their sum.输入格式:Each input file contains one test case. Each case starts with a positive integer N (≤100), foll

2020-07-08 15:34:58 161

原创 B1007 素数对猜想 (20分)【C语言】

B1007 素数对猜想 (20分)【C语言】原题链接易知所有素数都是奇数(因为偶数一定是2的倍数),只需要枚举1<p, p+2 <=n(其中p是奇数),并且判断p,p+2是否均为素数即可题目描述:让我们定义d​n​​ 为:d​n​​ =p​n+1​​ −p​n​​ ,其中p​i​​ 是第i个素数。显然有d​1​​ =1,且对于n>1有d​n​​ 是偶数。“素数对猜想”认为“存在无穷多对相邻且差为2的素数”。现给定任意正整数N(<10 ​5​​ ),请计算不超过N的满足猜想的

2020-07-07 17:36:18 144

原创 A1049 Counting Ones (30分)【C语言】

A1049 Counting Ones (30分)【C语言】原题链接题目描述:The task is simple: given any positive integer N, you are supposed to count the total number of 1’s in the decimal form of the integers from 1 to N. For example, given N being 12, there are five 1’s in 1, 10, 11, a

2020-07-06 17:53:57 146

原创 A1008 Elevator (20分)【C语言】

A1008 Elevator (20分)【C语言】原题链接to记录要去的楼层,now记录当前所处楼层,根据to和now的大小关系判断上楼、下楼还是停留在当前楼层(不需要上下楼时间,但要计算停留时间)。题目描述: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 e

2020-07-06 17:34:36 1566

转载 B1049/A1104 数列的片段和 (20分)【C语言】

B1049/A1104 数列的片段和 (20分)【C语言】原题链接对于第 i 个数字(下标从1开始) ,如果包含在片段[p, q]中,p的选择有 i 种,q 的选择有(n-i+1)种,因此包含i的片段有 i*(n-i+1)种,只需要遍历数组即可。改数据了…原来的代码第三个测试点无法通过了,参考了这位大佬的解题方法和代码题目描述:给定一个正数数列,我们可以从中截取任意的连续的几个数,称为片段。例如,给定数列 { 0.1, 0.2, 0.3, 0.4 },我们有 (0.1) (0.1, 0.2) (0

2020-07-06 17:24:02 123

原创 B1019/A1069 数字黑洞 (20分)【C语言】

B1019/A1069 数字黑洞 (20分)【C语言】原题链接要想对每一位数字进行排序,主要将数字转化为数组因此需要一个数字转数组的函数,和一个数组转数字的函数题目描述:给定任一个各位数字不完全相同的 4 位正整数,如果我们先把 4 个数字按非递增排序,再按非递减排序,然后用第 1 个数字减第 2 个数字,将得到一个新的数字。一直重复这样做,我们很快会停在有“数字黑洞”之称的 6174,这个神奇的数字也叫 Kaprekar 常数。例如,我们从6767开始,将得到7766 - 6677 = 1

2020-07-05 10:13:12 161

原创 B1003 我要通过! (20分)【C语言】

B1003 我要通过! (20分)【C语言】原题链接题目描述:“答案正确”是自动判题系统给出的最令人欢喜的回复。本题属于 PAT 的“答案正确”大派送 —— 只要读入的字符串满足下列条件,系统就输出“答案正确”,否则输出“答案错误”。得到“答案正确”的条件是:字符串中必须仅有 P、 A、 T这三种字符,不可以包含其它字符;任意形如 xPATx 的字符串都可以获得“答案正确”,其中 x 或者是空字符串,或者是仅由字母 A 组成的字符串;如果 aPbTc 是正确的,那么 aPbATca 也是正确

2020-07-05 09:40:50 192

原创 B1045/A1101 快速排序 (25分)【C语言】

B1045/A1101 快速排序 (25分)【C语言】原题链接题目描述:著名的快速排序算法里有一个经典的划分过程:我们通常采用某种方法取一个元素作为主元,通过交换,把比主元小的元素放到它的左边,比主元大的元素放到它的右边。 给定划分后的 N 个互不相同的正整数的排列,请问有多少个元素可能是划分前选取的主元?例如给定 N=5N = 5N=5, 排列是1、3、2、4、5。则:1 的左边没有元素,右边的元素都比它大,所以它可能是主元;尽管 3 的左边元素都比它小,但其右边的 2 比它小,所以它不能是

2020-07-04 17:25:52 154

原创 B1040/A1093 有几个PAT (25分)【C语言】

B1040/A1093 有几个PAT (25分)【C语言】原题链接只需要查找每个A的左边有i个P,右边有j个T,那么对于这个A而言,可以组成i*j个PAT要注意://不能用gets读入字符串,改用fgets,但要去掉读入的换行符fgets(str, maxn, stdin); for(int i=0; i<maxn; ++i){ if(str[i]=='\n'){ str[i]='\0'; break; } }题目描述:字符串 APPAPT 中包含了两个单词

2020-07-03 18:56:29 139

原创 B1035/A1089 插入与归并 (25分)【C语言】

B1035/A1089 插入与归并 (25分)【C语言】原题链接题目描述:根据维基百科的定义:插入排序是迭代算法,逐一获得输入数据,逐步产生有序的输出序列。每步迭代中,算法从输入序列中取出一元素,将之插入有序序列中正确的位置。如此迭代直到全部元素有序。归并排序进行如下迭代操作:首先将原始序列看成 N 个只包含 1 个元素的有序子序列,然后每次迭代归并两个相邻的有序子序列,直到最后只剩下 1 个有序的序列。现给定原始序列和由某排序算法产生的中间序列,请你判断该算法究竟是哪种排序算法?输入格式:

2020-07-03 18:38:48 162

原创 A1029 Median (25分)【C语言】

A1029 Median (25分)【C语言】原题链接题目描述:Given an increasing sequence S of N integers, the median is the number at the middle position. For example, the median of S1 = { 11, 12, 13, 14 } is 12, and the median of S2 = { 9, 10, 15, 16, 17 } is 15. The median of tw

2020-07-02 17:37:19 175

原创 A1010 Radix (25分)【C语言】

A1010 Radix (25分)【C语言】原题链接题目描述: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 integers N​1​​ and N​2​​ ,

2020-07-01 18:18:08 135

原创 A1022 Digital Library (30分)【C语言】

A1022 Digital Library (30分)【C语言】原题链接题目描述:A Digital Library contains millions of books, stored according to their titles, authors, key words of their abstracts, publishers, and published years. Each book is assigned an unique 7-digit number as its ID. Gi

2020-06-30 17:28:51 686

原创 A1071 Speech Patterns (25分)【C语言】

A1071 Speech Patterns (25分)【C语言】原题链接题目描述:People often have a preference among synonyms of the same word. For example, some may prefer “the police”, while others may prefer “the cops”. Analyzing such patterns can help to narrow down a speaker’s identity,

2020-06-30 17:02:26 109

原创 B1044/A1100 火星数字 (20分)【C语言】

B1044/A1100 火星数字 (20分)【C语言】原题链接题目描述:火星人是以 13 进制计数的:地球人的 0 被火星人称为 tret。地球人数字 1 到 12 的火星文分别为:jan, feb, mar, apr, may, jun, jly, aug, sep, oct, nov, dec。火星人将进位以后的 12 个高位数字分别称为:tam, hel, maa, huh, tou, kes, hei, elo, syy, lok, mer, jou。例如地球人的数字 29 翻译成

2020-06-29 11:27:14 173

原创 A1054 The Dominant Color (20分)【C语言】

A1054 The Dominant Color (20分)【C语言】原题链接本题即找出矩阵中出现次数最多的数字(因为题目已经保证会有过半的数字,因此不需要判断)。如果使用普通数组的话,可能会因为数据范围过大而导致内存超限。题目描述: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 i

2020-06-29 11:05:49 162

原创 A1060 Are They Equal (25分)【C语言】

A1060 Are They Equal (25分)【C语言】原题链接题目描述: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​​ with simple chopping. Now given the number of significant digit

2020-06-28 17:05:55 91

原创 A1063 Set Similarity (25分)【C语言】

A1063 Set Similarity (25分)【C语言】原题链接题目描述: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 the two sets, and N​t​​ is the total number of distinct

2020-06-27 15:33:41 111

原创 A1047 Student List for Course (25分)【C语言】

A1047 Student List for Course (25分)【C语言】原题链接题目描述:Zhejiang University has 40,000 students and provides 2,500 courses. Now given the registered course list of each student, you are supposed to output the student name lists of all the courses.输入格式:Each i

2020-06-26 22:22:16 136

原创 A1039 Course List for Student (25分)【C语言】

A1039 Course List for Student (25分)【C语言】原题链接如果使用二维数组存放学生所选课程编号,会导致最后一组数据内存超限,因此需要使用vector来减少空间消耗。题目描述: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

2020-06-26 21:55:22 177

原创 A1044 Shopping in Mars (25分)【C语言】

A1044 Shopping in Mars (25分)【C语言】原题链接题目描述: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 the payment, the chain can be cut at any position for only on

2020-06-21 21:59:24 456

原创 B1030/A1085 完美数列 (25分)【C语言】

B1030/A1085 完美数列 (25分)【C语言】原题链接题目描述:给定一个正整数数列,和正整数 p,设这个数列中的最大值是 M,最小值是 m,如果 M≤mp,则称这个数列是完美数列。现在给定参数 p 和一些正整数,请你从中选择尽可能多的数构成一个完美数列。输入格式:输入第一行给出两个正整数 N 和 p,其中 N(≤10 ​5​​ )是输入的正整数的个数,p(≤10 ​9​​ )是给定的参数。第二行给出 N 个正整数,每个数不超过 10 ​9​​ 。输出格式:在一行中输出最多可以选择多少

2020-06-21 20:54:42 238

原创 A1038 Recover the Smallest Number (30分)【C语言】

A1038 Recover the Smallest Number (30分)【C语言】原题链接用到了好多字符串的功能哦…题目描述: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 recover many numbers such like 32

2020-06-20 22:57:36 152

原创 A1067 Sort with Swap(0, i) (25分)【C语言】

A1067 Sort with Swap(0, i) (25分)【C语言】原题链接题目描述:Given any permutation of the numbers {0, 1, 2,…, N−1}, it is easy to sort them in increasing order. But what if Swap(0, *) is the ONLY operation that is allowed to use? For example, to sort {4, 0, 2, 1, 3} w

2020-06-20 22:36:04 142

原创 A1037 Magic Coupon (25分)【C语言】

A1037 Magic Coupon (25分)【C语言】原题链接题目描述: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 product, you may get N times the value of that product back! What is mo

2020-06-20 22:14:09 118

空空如也

空空如也

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

TA关注的人

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