当前位置:网站首页>2019年9月PAT甲级题目
2019年9月PAT甲级题目
2022-07-28 10:15:00 【小柳学渣】
7-1 Forever (20分)
“Forever number” is a positive integer A with K digits, satisfying the following constrains:
- the sum of all the digits of A is m;
- the sum of all the digits of A+1 is n; and
- the greatest common divisor of m and n is a prime number which is greater than 2.
Now you are supposed to find these forever numbers.
Input Specification:
Each input file contains one test case. For each test case, the first line contains a positive integer N (≤5). Then N lines follow, each gives a pair of K (3<K<10) and m (1<m<90), of which the meanings are given in the problem description.
Output Specification:
For each pair of K and m, first print in a line Case X, where X is the case index (starts from 1). Then print n and A in the following line. The numbers must be separated by a space. If the solution is not unique, output in the ascending order of n. If still not unique, output in the ascending order of A. If there is no solution, output No Solution.
Sample Input:
2
6 45
7 80
Sample Output:
Case 1
10 189999
10 279999
10 369999
10 459999
10 549999
10 639999
10 729999
10 819999
10 909999
Case 2
No Solution
7-2 Merging Linked Lists (25分)
Given two singly linked lists L1=a1→a2→⋯→an−1→an and L2=b1→b2→⋯→bm−1→bm. If n≥2m, you are supposed to reverse and merge the shorter one into the longer one to obtain a list like a1→a2→bm→a3→a4→bm−1⋯. For example, given one list being 6→7 and the other one 1→2→3→4→5, you must output 1→2→7→3→4→6→5.
Input Specification:
Each input file contains one test case. For each case, the first line contains the two addresses of the first nodes of L1 and L2, plus a positive N (≤10^5) which is the total number of nodes given. The address of a node is a 5-digit nonnegative integer, and NULL is represented by -1.
Then N lines follow, each describes a node in the format:
Address Data Next
where Address is the position of the node, Data is a positive integer no more than 10^5, and Next is the position of the next node. It is guaranteed that no list is empty, and the longer list is at least twice as long as the shorter one.
Output Specification:
For each case, output in order the resulting linked list. Each node occupies a line, and is printed in the same format as in the input.
Sample Input:
00100 01000 7
02233 2 34891
00100 6 00001
34891 3 10086
01000 1 02233
00033 5 -1
10086 4 00033
00001 7 -1
Sample Output:
01000 1 02233
02233 2 00001
00001 7 34891
34891 3 10086
10086 4 00100
00100 6 00033
00033 5 -1
边栏推荐
- 8. Numbers that appear more than half of the time in the array
- ogg参数filter的使用问题【急】
- 16、字符串反转
- PHP generates QR code (learning)
- 16. String inversion
- Voice chat app - how to standardize the development process?
- 胡润发布2020中国芯片设计10强民营企业:华为海思竟然没有上榜!
- 12. Double pointer -- merge two ordered linked lists
- Sleeping barber problem
- 配置树莓派,过程和遇到问题
猜你喜欢

用两个栈实现一个队列【C语言】

gcc: error trying to exec 'as': execvp: No such file or directory

Voice chat app - how to standardize the development process?

It's settled! On July 30!

多线程与高并发(三)—— 源码解析 AQS 原理

【栈的应用】--- 中缀表达式转后缀表达式

uni-app项目目录、文件作用介绍 及 开发规范

SQL Server 2016 学习记录 --- 数据更新

AP Autosar平台设计 3架构

第一篇:UniAPP的小程序跨端开发-----创建uniapp项目
随机推荐
最短路专题
上下文变量值(context values)陷阱及在 Go 中如何避免或缓和这些陷阱
指令系统超全知识点详解
KingbaseES V8R6 JDBC 能否使用VIP ?
Alibaba cloud image address
Elk real time log analysis platform
JVM principle
管道、管程、管态的区别
2. Output one of the repeated numbers in the array
Uni app advanced creation component / native rendering
Leetcode -- minimum number of rotation array
Small knowledge in Oracle
Consul
Oracle中的小知识
ACM寒假集训#6
Typora使用教程
在mt6735中添加新的开机logo与开\关机动画
India plans to ban China Telecom equipment! Can we really do without Huawei and ZTE?
14、双指针——盛最多水的容器
Hurun released the 2020 top 10 Chinese chip design private enterprises: Huawei Hisilicon did not appear on the list!