随笔分类 -  PAT甲级

1 2 3 4 5 下一页

1021 个位数统计 (15 分)map的使用
摘要:1021 个位数统计 (15 分) 给定一个 k 位整数 N=d​k−1​​10​k−1​​+⋯+d​1​​10​1​​+d​0​​ (0≤d​i​​≤9, i=0,⋯,k−1, d​k−1​​>0),请编写程序统计每种不同的个位数字出现的次数。例如:给定 N=100311,则有 2 个 0,3 个 阅读全文

posted @ 2019-02-19 19:04 ZhangのBlog 阅读(193) 评论(0) 推荐(0)

1101 Quick Sort (25 分)递推
摘要:1101 Quick Sort (25 分) There is a classical process named partition in the famous quick sort algorithm. In this process we typically choose one elemen 阅读全文

posted @ 2019-02-14 19:27 ZhangのBlog 阅读(252) 评论(0) 推荐(0)

1101 Quick Sort (25 分)
摘要:1101 Quick Sort (25 分) There is a classical process named partition in the famous quick sort algorithm. In this process we typically choose one elemen 阅读全文

posted @ 2019-02-14 19:07 ZhangのBlog 阅读(217) 评论(0) 推荐(0)

1105 Spiral Matrix (25 分)螺旋矩阵
摘要:1105 Spiral Matrix (25 分) This time your job is to fill a sequence of N positive integers into a spiral matrix in non-increasing order. A spiral matri 阅读全文

posted @ 2019-02-14 17:01 ZhangのBlog 阅读(156) 评论(0) 推荐(0)

1089 Insert or Merge (25 分)
摘要:1089 Insert or Merge (25 分) According to Wikipedia: Insertion sort iterates, consuming one input element each repetition, and growing a sorted output 阅读全文

posted @ 2019-02-14 14:47 ZhangのBlog 阅读(548) 评论(0) 推荐(0)

1044 Shopping in Mars (25 分)二分查找
摘要:1044 Shopping in Mars (25 分) Shopping in Mars is quite a different experience. The Mars people pay by chained diamonds. Each diamond has a value (in M 阅读全文

posted @ 2019-02-14 13:33 ZhangのBlog 阅读(144) 评论(0) 推荐(0)

1068 Find More Coins (30 分)记忆化搜索
摘要:1068 Find More Coins (30 分) Eva loves to collect coins from all over the universe, including some other planets like Mars. One day she visited a unive 阅读全文

posted @ 2019-02-13 20:53 ZhangのBlog 阅读(1085) 评论(0) 推荐(0)

1133 Splitting A Linked List (25 分)
摘要: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 befo 阅读全文

posted @ 2019-02-13 18:28 ZhangのBlog 阅读(139) 评论(0) 推荐(0)

1145 Hashing - Average Search Time (25 分)
摘要: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. 阅读全文

posted @ 2019-02-13 15:31 ZhangのBlog 阅读(132) 评论(0) 推荐(0)

1147 Heaps (30 分)
摘要: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, 阅读全文

posted @ 2019-02-13 14:23 ZhangのBlog 阅读(129) 评论(0) 推荐(0)

1098 Insertion or Heap Sort (25 分)
摘要:1098 Insertion or Heap Sort (25 分) According to Wikipedia: Insertion sort iterates, consuming one input element each repetition, and growing a sorted 阅读全文

posted @ 2019-02-13 13:22 ZhangのBlog 阅读(174) 评论(0) 推荐(0)

自测-3 数组元素循环右移问题 (20 分)
摘要:自测-3 数组元素循环右移问题 (20 分) 一个数组AAA中存有NNN(>0>0>0)个整数,在不允许使用另外数组的前提下,将每个整数循环向右移MMM(≥0\ge 0≥0)个位置,即将AAA中的数据由(A0A1⋯AN−1A_0 A_1 \cdots A_{N-1}A​0​​A​1​​⋯A​N−1​ 阅读全文

posted @ 2019-02-08 20:59 ZhangのBlog 阅读(616) 评论(0) 推荐(0)

自测-1 打印沙漏 (20 分)
摘要:自测-1 打印沙漏 (20 分) 本题要求你写个程序把给定的符号打印成沙漏的形状。例如给定17个“*”,要求按下列格式打印 ***** *** * *** ***** 所谓“沙漏形状”,是指每行输出奇数个符号;各行符号中心对齐;相邻两行符号数差2;符号数先从大到小顺序递减到1,再从小到大顺序递增;首 阅读全文

posted @ 2019-02-08 20:38 ZhangのBlog 阅读(1070) 评论(0) 推荐(0)

1088 Rational Arithmetic (20 分)
摘要:1088 Rational Arithmetic (20 分) For two rational numbers, your task is to implement the basic arithmetics, that is, to calculate their sum, difference 阅读全文

posted @ 2019-02-02 14:05 ZhangのBlog 阅读(163) 评论(0) 推荐(0)

1081 Rational Sum (20 分)分数加法
摘要:1081 Rational Sum (20 分) Given N rational numbers in the form numerator/denominator, you are supposed to calculate their sum. Input Specification: Eac 阅读全文

posted @ 2019-02-02 12:49 ZhangのBlog 阅读(432) 评论(0) 推荐(0)

1104 Sum of Number Segments (20 分)有超时
摘要:1104 Sum of Number Segments (20 分) Given a sequence of positive numbers, a segment is defined to be a consecutive subsequence. For example, given the 阅读全文

posted @ 2019-02-01 19:20 ZhangのBlog 阅读(158) 评论(0) 推荐(0)

1007 素数对猜想 (20 分)
摘要:1007 素数对猜想 (20 分) 让我们定义d​n​​为:d​n​​=p​n+1​​−p​n​​,其中p​i​​是第i个素数。显然有d​1​​=1,且对于n>1有d​n​​是偶数。“素数对猜想”认为“存在无穷多对相邻且差为2的素数”。 现给定任意正整数N(<10​5​​),请计算不超过N的满足猜想 阅读全文

posted @ 2019-02-01 18:34 ZhangのBlog 阅读(155) 评论(0) 推荐(0)

1013 数素数 (20 分)
摘要:1013 数素数 (20 分) 令 P​i​​ 表示第 i 个素数。现任给两个正整数 M≤N≤10​4​​,请输出 P​M​​ 到 P​N​​ 的所有素数。 输入格式: 输入在一行中给出 M 和 N,其间以空格分隔。 输出格式: 输出从 P​M​​ 到 P​N​​ 的所有素数,每 10 个数字占 1 阅读全文

posted @ 2019-02-01 18:17 ZhangのBlog 阅读(628) 评论(0) 推荐(0)

1059 Prime Factors (25 分)素数 “筛选法”
摘要:1059 Prime Factors (25 分) Given any positive integer NNN, you are supposed to find all of its prime factors, and write them in the format NNN = p1k1×p 阅读全文

posted @ 2019-02-01 16:51 ZhangのBlog 阅读(304) 评论(0) 推荐(0)

1039 Course List for Student (25 分)map and set
摘要:1039 Course List for Student (25 分) Zhejiang University has 40000 students and provides 2500 courses. Now given the student name lists of all the cour 阅读全文

posted @ 2019-02-01 15:19 ZhangのBlog 阅读(322) 评论(0) 推荐(0)

1 2 3 4 5 下一页