摘要: Given N rational numbers in the form "numerator/denominator", you are supposed to calculate their sum. Input Specification: Each input file contains o 阅读全文
posted @ 2018-02-04 19:55 ZHUQW 阅读(127) 评论(0) 推荐(0) 编辑
摘要: The task is simple: given any positive integer N, you are supposed to count the total number of 1's in the decimal form of the integers from 1 to N. F 阅读全文
posted @ 2018-02-04 19:13 ZHUQW 阅读(124) 评论(0) 推荐(0) 编辑
摘要: 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 elev 阅读全文
posted @ 2018-02-04 18:09 ZHUQW 阅读(89) 评论(0) 推荐(0) 编辑
摘要: Given a sequence of positive numbers, a segment is defined to be a consecutive subsequence. For example, given the sequence {0.1, 0.2, 0.3, 0.4}, we h 阅读全文
posted @ 2018-02-04 16:52 ZHUQW 阅读(76) 评论(0) 推荐(0) 编辑
摘要: “答案正确”是自动判题系统给出的最令人欢喜的回复。本题属于PAT的“答案正确”大派送 —— 只要读入的字符串满足下列条件,系统就输出“答案正确”,否则输出“答案错误”。 得到“答案正确”的条件是: 1. 字符串中必须仅有P, A, T这三种字符,不可以包含其它字符;2. 任意形如 xPATx 的字符 阅读全文
posted @ 2018-02-04 16:05 ZHUQW 阅读(148) 评论(0) 推荐(0) 编辑
摘要: 二分查找 1、查找某元素。循环条件 low <= high,最终结果位mid, 如果查询失败则返回-1。 2、查找第一个满足条件的元素。 1)被排好序的待搜索序列一定是从左到右先不满足条件,然后满足条件; 2)传入的high = N时,在搜索不到满足条件的数时,会返回N(假想N位置有数字); 若不想 阅读全文
posted @ 2018-02-04 15:06 ZHUQW 阅读(354) 评论(0) 推荐(0) 编辑
摘要: For any 4-digit integer except the ones with all the digits being the same, if we sort the digits in non-increasing order first, and then in non-decre 阅读全文
posted @ 2018-02-04 14:07 ZHUQW 阅读(183) 评论(0) 推荐(0) 编辑
摘要: There is a classical process named partition in the famous quick sort algorithm. In this process we typically choose one element as the pivot. Then th 阅读全文
posted @ 2018-02-04 13:35 ZHUQW 阅读(124) 评论(0) 推荐(0) 编辑
摘要: The string APPAPT contains two PAT's as substrings. The first one is formed by the 2nd, the 4th, and the 6th characters, and the second one is formed 阅读全文
posted @ 2018-02-04 12:07 ZHUQW 阅读(91) 评论(0) 推荐(0) 编辑
摘要: Given an increasing sequence S of N integers, the median is the number at the middle position. For example, the median of S1={11, 12, 13, 14} is 12, a 阅读全文
posted @ 2018-02-04 10:45 ZHUQW 阅读(95) 评论(0) 推荐(0) 编辑