天南之城的后花园

记录精彩的程序人生

文章

PAT 1009 多项式乘法

1009 Product of Polynomials This time, you are supposed to find A×B where A and B are two polynomials. 这次,你需要找到两个多项式 A 和 B 的乘积。 Input Specification: Each input file contains one test case. Each case occupies 2 lines, and each line contains the information of a polynomial: K\quad N_1\quad a_{N1}\quad N_2\quad a_{N2}\quad...\quad N_K\quad a_{NK} where K is the number of nonzero terms in the polynomial, N_i and a_{Ni} (i=1,2,⋯,K) are the exponents and coefficients, respectively. It is given that $....

PAT 1008 电梯

1008 Elevator 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 elevator will stop, in specified order. It costs 6 seconds to move the elevator up one floor, and 4 seconds to move down one floor. The elevator will stay for 5 seconds at each stop. 我们城市最高的建筑只有一台电梯。有一个请求列表由 N 个正整数组成,这些数字指定电梯停在哪些楼层,按指定的顺序。电梯每上升一层需要 6 秒钟,每下降一层需要 4 秒钟。电梯每停留一个楼层需要 5 秒钟。 For a given request list, you are to compute the total ....

PAT 1007 最大子序列和

1007 Maximum Subsequence Sum Given a sequence of K integers { N1, N2, ..., N**K }. A continuous subsequence is defined to be { N**i, N**i+1, ..., N**j } where 1≤i≤j≤K. The Maximum Subsequence is the continuous subsequence which has the largest sum of its elements. For example, given sequence { -2, 11, -4, 13, -5, -2 }, its maximum subsequence is { 11, -4, 13 } with the largest sum being 20. Now you are supposed to find the largest sum, together with the first and the last numbers of the maximum ....

PAT 1006 签到与签退

1006 Sign In and Sign Out At the beginning of every day, the first person who signs in the computer room will unlock the door, and the last one who signs out will lock the door. Given the records of signing in's and out's, you are supposed to find the ones who have unlocked and locked the door on that day. 每天开始时,第一个在电脑房签到的人将解锁门,最后一个签退的人将锁门。给定签到和签退的记录,你需要找出当天解锁和锁门的人。 Input Specification: Each input file contains one test case. Each case contains the records for one day. The case starts with a pos....

PAT 1005 正确拼写

1005 Spell It Right Given a non-negative integer N, your task is to compute the sum of all the digits of N, and output every digit of the sum in English. 给定一个非负整数N,你的任务是计算N的所有数字的和,并输出总和的每个数字的英文表示。 Input Specification: Each input file contains one test case. Each case occupies one line which contains an N (≤10^{100}). 每个输入文件包含一个测试用例。每个测试用例占据一行,其中包含一个N(≤10^{100})。 Output Specification: For each test case, output in one line the digits of the sum in English words. There must be one space between tw....

PAT 1004 数叶子

1004 Counting Leaves A family hierarchy is usually presented by a pedigree tree. Your job is to count those family members who have no child. 一个家庭的层级结构通常用家谱树来表示。你的任务是统计那些没有孩子的家庭成员。 输入格式: Each input file contains one test case. Each case starts with a line containing 0<N<100, the number of nodes in a tree, and M (<N), the number of non-leaf nodes. Then M lines follow, each in the format: ID K ID[1] ID[2] ... ID[K] where ID is a two-digit number representing a given non-leaf node, K is t....

PAT 1003 迪杰斯特拉算法详解

迪杰斯特拉算法 万物基于传销——硬核的半佛仙人 题目是PAT的题目,Advanced Level 1003 Emergency 代码是github的代码,原仓库地址https://github.com/liuchuo/PAT 1003 Emergency 紧急事件 As an emergency rescue team leader of a city, you are given a special map of your country. The map shows several scattered cities connected by some roads. Amount of rescue teams in each city and the length of each road between any pair of cities are marked on the map. When there is an emergency call to you from some other city, your job is to lead your men to the....

PAT 1003 紧急救援

1003 Emergency 紧急事件 As an emergency rescue team leader of a city, you are given a special map of your country. The map shows several scattered cities connected by some roads. Amount of rescue teams in each city and the length of each road between any pair of cities are marked on the map. When there is an emergency call to you from some other city, your job is to lead your men to the place as quickly as possible, and at the mean time, call up as many hands on the way as possible. 作为一名城市的紧急救援队队长,你....

PAT 1002 两多项式相加

1002 A+B for Polynomials This time, you are supposed to find A+B where A and B are two polynomials. 这次,你需要找到两个多项式A和B的和。 Input Specification: Each input file contains one test case. Each case occupies 2 lines, and each line contains the information of a polynomial: K N_1 a_{N1} N_2 a_{N2} ... N_{K} a_{NK} where K is the number of nonzero terms in the polynomial, N_{i} and a_{Ki} (i=1,2,⋯,K) are the exponents and coefficients, respectively. It is given that 1≤K≤10 , 0≤N_{K}<⋯<N_{2}<N_{1}....

PAT 1001 两数相加

1001 A+B Format Calculate a+b and output the sum in standard format -- that is, the digits must be separated into groups of three by commas (unless there are less than four digits). 计算a+b并以标准格式输出——也就是说,除非数字少于四位,否则数字必须用逗号分隔成三组。 Input Specification: Each input file contains one test case. Each case contains a pair of integers a and b where −106≤a,b≤106. The numbers are separated by a space. 每个输入文件包含一个测试用例。每个用例包含一对整数a和b,其中−106≤a,b≤106。数字由空格分隔。 Output Specification: For each test case, you should ou....

记录精彩的程序人生

© 2025 天南之城的后花园

Powered by Bolo
Theme bolo-sakura by Mashiro
浏览 50926 文章 43 评论 11
蜀ICP备2023008301号

主题 | Theme