第 1 章 Java语言概述 * Java语言有哪些特点? 答:简单易学、面向对象、平台无关性、可靠性、安全性、支持多线程、支持网络编程、编译与解释并存 * 什么是Java的虚拟机? 答:任何一种可以运行Java字节码的软件均可看成是Java的虚拟机 * 什么是字节码?采用字节码的最大好处是什么? 答:字节码是Java虚拟机的指令组,和CPU上的微指令很相似 。字节码最大的好处是可跨平台运行 * 什么是平台无关性?Java语言是怎样实现平台无关性的? 答:编写的应用程序不用修
Read more »

The K-P factorization of a positive integer N is to write N as the sum of the P-th power of K positive integers. You are supposed to write a program to find the K-P factorization of N for any positive integers N, K and P. Input Specification: Each input file contains one test case which gives in a
Read more »

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 in order to become a FatMouse. First the playing order is randomly decided for NP progr
Read more »

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} we may apply the swap operations in the following way: Swap(0, 1) => {4, 1, 2, 0, 3} Swap(0, 3
Read more »

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 prime. Now given any two positive integers N (<105​) and D (1
Read more »

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 consecutive numbers. Now given any positive N, you are supposed to find the maximum number of consecutive factors, and list the sma
Read more »

To evaluate the performance of our first year CS majored students, we consider their grades of three courses only:C- C Programming Language,M- Mathematics (Calculus or Linear Algrbra), andE- English. At the mean time, we encourage students by emphasizing on their best ranks – that is, among the four
Read more »

每次 PAT 考试结束后,考试中心都会发布一个考生单位排行榜。本题就请你实现这个功能。 输入格式: 输入第一行给出一个正整数 N(≤10 5),即考生人数。随后 N 行,每行按下列格式给出一个考生的信息: 准考证号 得分 学校 其中准考证号是由 6 个字符组成的字符串,其首字母表示考试的级别:B代表乙级,A代表甲级,T代表顶级;得分是 [0, 100] 区间内的整数;学校是由不超过 6 个英文字母组成的单位码(大小写无关)。注意:题目保证每个考生的准考证号是不同的。 输出格式: 首先在一行中输出单位个数。随后按以下格式非降序输出单位的排行榜: 排名 学校 加权总分 考生人数 其中
Read more »

外观数列是指具有以下特点的整数序列: d, d1, d111, d113, d11231, d112213111, … 它从不等于 1 的数字d开始,序列的第 n+1 项是对第 n 项的描述。比如第 2 项表示第 1 项有 1 个d,所以就是d1;第 2 项是 1 个d(对应d1)和 1 个 1(对应 11),所以第 3 项就是d111。又比如第 4 项是d113,其描述就是 1 个d,2 个 1,1 个 3,所以下一项就是d11231。当然这个定义对d= 1 也成立。本题要求你推算任意给定数字d的外观数列的第 N 项。 输入格式: 输入第一行给出 [0,9] 范围内的一个整数d、以及一
Read more »

给定 N 张卡片,正面分别写上 1、2、……、N,然后全部翻面,洗牌,在背面分别写上 1、2、……、N。将每张牌的正反两面数字相减(大减小),得到 N 个非负差值,其中是否存在相等的差? 输入格式: 输入第一行给出一个正整数 N(2 ≤ N ≤ 10 000),随后一行给出 1 到 N 的一个洗牌后的排列,第 i 个数表示正面写了 i 的那张卡片背面的数字。 输出格式: 按照“差值 重复次数”的格式从大到小输出重复的差值及其重复的次数,每行输出一个结果。 输入样例: 8 3 5 8 6 2 1 4 7 输出样例: 5 2 3 3 2 2 这里可以利用map的key是有序的特点,将差值
Read more »
0%