摘要:1021 个位数统计 (15 分) 给定一个 k 位整数 N=dk−110k−1+⋯+d1101+d0 (0≤di≤9, i=0,⋯,k−1, dk−1>0),请编写程序统计每种不同的个位数字出现的次数。例如:给定 N=100311,则有 2 个 0,3 个
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要:1089 Insert or Merge (25 分) According to Wikipedia: Insertion sort iterates, consuming one input element each repetition, and growing a sorted output
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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.
阅读全文
摘要: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,
阅读全文
摘要:1098 Insertion or Heap Sort (25 分) According to Wikipedia: Insertion sort iterates, consuming one input element each repetition, and growing a sorted
阅读全文
摘要:自测-3 数组元素循环右移问题 (20 分) 一个数组AAA中存有NNN(>0>0>0)个整数,在不允许使用另外数组的前提下,将每个整数循环向右移MMM(≥0\ge 0≥0)个位置,即将AAA中的数据由(A0A1⋯AN−1A_0 A_1 \cdots A_{N-1}A0A1⋯AN−1
阅读全文
摘要:自测-1 打印沙漏 (20 分) 本题要求你写个程序把给定的符号打印成沙漏的形状。例如给定17个“*”,要求按下列格式打印 ***** *** * *** ***** 所谓“沙漏形状”,是指每行输出奇数个符号;各行符号中心对齐;相邻两行符号数差2;符号数先从大到小顺序递减到1,再从小到大顺序递增;首
阅读全文
摘要:1088 Rational Arithmetic (20 分) For two rational numbers, your task is to implement the basic arithmetics, that is, to calculate their sum, difference
阅读全文
摘要:1081 Rational Sum (20 分) Given N rational numbers in the form numerator/denominator, you are supposed to calculate their sum. Input Specification: Eac
阅读全文
摘要: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
阅读全文
摘要:1007 素数对猜想 (20 分) 让我们定义dn为:dn=pn+1−pn,其中pi是第i个素数。显然有d1=1,且对于n>1有dn是偶数。“素数对猜想”认为“存在无穷多对相邻且差为2的素数”。 现给定任意正整数N(<105),请计算不超过N的满足猜想
阅读全文
摘要:1013 数素数 (20 分) 令 Pi 表示第 i 个素数。现任给两个正整数 M≤N≤104,请输出 PM 到 PN 的所有素数。 输入格式: 输入在一行中给出 M 和 N,其间以空格分隔。 输出格式: 输出从 PM 到 PN 的所有素数,每 10 个数字占 1
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文