
数学问题
小·幸·运
你的所有努力最后都会回赠予你。
展开
-
leetcode-168. Excel表列名称
给定一个正整数,返回它在 Excel 表中相对应的列名称。例如, 1 -> A 2 -> B 3 -> C ... 26 -> Z 27 -> AA 28 -> AB ...示例 1:输入: 1输出: "A"示例2:输入: 28输出: "AB"示例3:输入: 701输出: "ZY"思路:这是一个26进制的转换题,把1-26变成对应的A-Z,但是要注意,在对n求余数时...原创 2021-02-24 18:26:52 · 102 阅读 · 0 评论 -
PAT乙级B1034 有理数四则运算 (20 分)
本题要求编写程序,计算 2 个有理数的和、差、积、商。输入格式:输入在一行中按照 a1/b1 a2/b2 的格式给出两个分数形式的有理数,其中分子和分母全是整型范围内的整数,负号只可能出现在分子前,分母不为 0。输出格式:分别在 4 行中按照 有理数1 运算符 有理数2 = 结果 的格式顺序输出 2 个有理数的和、差、积、商。注意输出的每个有理数必须是该有理数的最简形式 k a/b...原创 2019-01-29 15:05:56 · 154 阅读 · 0 评论 -
PAT甲级A1088 Rational Arithmetic (20 分)
For two rational numbers, your task is to implement the basic arithmetics, that is, to calculate their sum, difference, product and quotient.Input Specification:Each input file contains one test c...原创 2019-02-22 16:25:07 · 195 阅读 · 0 评论 -
LeetCode--942. DI String Match
Given a string S that only contains "I" (increase) or "D" (decrease), let N = S.length.Return any permutation A of [0, 1, ..., N] such that for all i = 0, ..., N-1:If S[i] == "I", then A[i] < A...原创 2019-02-11 21:55:05 · 175 阅读 · 0 评论 -
LeetCode--973. K Closest Points to Origin
We have a list of points on the plane. Find the K closest points to the origin (0, 0).(Here, the distance between two points on a plane is the Euclidean distance.)You may return the answer in any...原创 2019-02-12 22:31:31 · 169 阅读 · 0 评论 -
PAT甲级A1096 Consecutive Factors (20 分)
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 ...原创 2019-02-23 21:44:13 · 236 阅读 · 0 评论 -
PAT甲级A1078 Hashing (25 分)
The task of this problem is simple: insert a sequence of distinct positive integers into a hash table, and output the positions of the input numbers. The hash function is defined to be H(key)=key%TSiz...原创 2019-02-18 19:20:08 · 260 阅读 · 0 评论 -
PAT甲级A1117 Eddington Number (25 分)
British astronomer Eddington liked to ride a bike. It is said that in order to show off his skill, he has even defined an "Eddington number", E -- that is, the maximum integer E such that it is for E ...原创 2019-03-01 17:09:49 · 213 阅读 · 0 评论 -
PAT甲级A1081 Rational Sum (20 分)
Given N rational numbers in the form numerator/denominator, you are supposed to calculate their sum.Input Specification:Each input file contains one test case. Each case starts with a positive int...原创 2019-02-20 14:00:06 · 177 阅读 · 0 评论 -
PAT甲级A1103 Integer Factorization (30 分)
The K−PK-PK−P factorization of a positive integer NNN is to write NNN as the sum of the PPP-th power of KKK positive integers. You are supposed to write a program to find the K−PK-PK−P factorization o...原创 2019-02-26 14:59:21 · 266 阅读 · 0 评论 -
PAT乙级B1051 复数乘法 (15 分)
复数可以写成 (A+Bi) 的常规形式,其中 A 是实部,B 是虚部,i 是虚数单位,满足 i2=−1;也可以写成极坐标下的指数形式 (R×e(Pi)),其中 R 是复数模,P 是辐角,i 是虚数单位,其等价于三角形式 (R(cos(P)+isin(P))。现给定两个复数的 R 和 P,要求输出两数乘积的常规形式。输入格式:输入在一行中依次给出两个复数的 R1, P...原创 2019-03-03 15:47:15 · 170 阅读 · 0 评论 -
PAT甲级A1152 Google Recruitment (20 分)
In July 2004, Google posted on a giant billboard along Highway 101 in Silicon Valley (shown in the picture below) for recruitment. The content is super-simple, a URL consisting of the first 10-digit p...原创 2019-03-15 16:47:59 · 273 阅读 · 0 评论 -
PAT乙级B1094 谷歌的招聘 (20 分)
1094 谷歌的招聘 (20 分)2004 年 7 月,谷歌在硅谷的 101 号公路边竖立了一块巨大的广告牌(如下图)用于招聘。内容超级简单,就是一个以 .com 结尾的网址,而前面的网址是一个 10 位素数,这个素数是自然常数 e 中最早出现的 10 位连续数字。能找出这个素数的人,就可以通过访问谷歌的这个网站进入招聘流程的下一步。自然常数 e 是一个著名的超越数,前面若干位写出来是...原创 2019-03-16 13:43:44 · 329 阅读 · 0 评论 -
PAT甲级A1059 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×p2k2×⋯×pmkm{p_1}^{k_1}\times {p_2}^{k_2} \times \cdots \times {p_m}^{k_m}p1...原创 2019-01-22 20:58:53 · 267 阅读 · 0 评论 -
PAT甲级A1065 A+B and C (64bit) (20 分)
Given three integers A, B and C in [−263,263], you are supposed to tell whether A+B>C.Input Specification:The first line of the input gives the positive number of test cases, T (≤10). The...原创 2019-01-25 17:07:12 · 228 阅读 · 0 评论 -
PAT甲级A1023 Have Fun with Numbers (20)
Notice that the number 123456789 is a 9-digit number consisting exactly the numbers from 1 to 9, with no duplication. Double it we will obtain 246913578, which happens to be another 9-digit number con...原创 2018-08-13 21:45:13 · 166 阅读 · 0 评论 -
PAT乙级B1019 数字黑洞 (20)
给定任一个各位数字不完全相同的4位正整数,如果我们先把4个数字按非递增排序,再按非递减排序,然后用第1个数字减第2个数字,将得到一个新的数字。一直重复这样做,我们很快会停在有“数字黑洞”之称的6174,这个神奇的数字也叫Kaprekar常数。例如,我们从6767开始,将得到7766 - 6677 = 1089\9810 - 0189 = 9621\9621 - 1269 = 8352\85...原创 2018-05-23 21:04:39 · 246 阅读 · 0 评论 -
LeetCode--628. Maximum Product of Three Numbers
Given an integer array, find three numbers whose product is maximum and output the maximum product.Example 1:Input: [1,2,3]Output: 6 Example 2:Input: [1,2,3,4]Output: 24 Note:The l...原创 2018-06-04 20:15:21 · 174 阅读 · 0 评论 -
LeetCode--67. Add Binary
Given two binary strings, return their sum (also a binary string).The input strings are both non-empty and contains only characters 1 or 0.Example 1:Input: a = "11", b = "1"Output: "100"Example 2:Inp...原创 2018-06-11 19:58:08 · 141 阅读 · 0 评论 -
LeetCode-832-Flipping an Image
Given a binary matrix A, we want to flip the image horizontally, then invert it, and return the resulting image.To flip an image horizontally means that each row of the image is reversed. For example...原创 2018-05-24 20:01:12 · 315 阅读 · 0 评论 -
LeetCode--268. Missing Number
Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array.Example 1:Input: [3,0,1]Output: 2Example 2:Input: [9,6,4,2,3,5,7,0,1]Output: 8N...原创 2018-05-29 20:27:30 · 170 阅读 · 0 评论 -
LeetCode--13. Roman to Integer
Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M.Symbol ValueI 1V 5X 10L 50C 100D 5...原创 2018-06-12 21:23:30 · 137 阅读 · 0 评论 -
PAT乙级B1022 D进制的A+B (20)
1022 D进制的A+B (20)(20 分)输入两个非负10进制整数A和B(<=2^30^-1),输出A+B的D (1 < D <=10)进制数。输入格式:输入在一行中依次给出3个整数A、B和D。输出格式:输出A+B的D进制数。输入样例:123 456 8输出样例:1103作者: CHEN, Yue单位: PAT联盟时间限制: 100ms内存限制: 64MB代码长度限制: ...原创 2018-07-13 21:56:35 · 146 阅读 · 0 评论 -
PAT甲级A1009 Product of Polynomials (25)
This time, you are supposed to find A*B where A and B are two polynomials.Input Specification:Each input file contains one test case. Each case occupies 2 lines, and each line contains the informa...原创 2018-07-25 21:28:49 · 127 阅读 · 0 评论 -
PAT甲级A1015 Reversible Primes (20)
A reversible prime in 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 pr...原创 2018-07-30 22:25:19 · 136 阅读 · 0 评论 -
PAT甲级A1024 Palindromic Number (25)
A number that will be the same when it is written forwards or backwards is known as a Palindromic Number. For example, 1234321 is a palindromic number. All single digit numbers are palindromic numbers...原创 2018-08-14 21:17:49 · 162 阅读 · 0 评论 -
PAT甲级A1019 General Palindromic Number (20)
A number that will be the same when it is written forwards or backwards is known as a Palindromic Number. For example, 1234321 is a palindromic number. All single digit numbers are palindromic numbers...原创 2018-08-07 21:31:45 · 137 阅读 · 0 评论 -
PAT甲级A1027 Colors in Mars (20)
People in Mars represent the colors in their computers in a similar way as the Earth people. That is, a color is represented by a 6-digit number, where the first 2 digits are for Red, the middle 2 dig...原创 2018-08-15 22:04:14 · 131 阅读 · 0 评论 -
PAT乙级B1017 A除以B (20)(20 分)
本题要求计算A/B,其中A是不超过1000位的正整数,B是1位正整数。你需要输出商数Q和余数R,使得A= B * Q + R成立。输入格式:输入在1行中依次给出A和B,中间以1空格分隔。输出格式:在1行中依次输出Q和R,中间以1空格分隔。输入样例:123456789050987654321 7输出样例:17636684150141093474 3作者: CHEN, Yue单位: PAT联盟时间...原创 2018-05-22 19:49:27 · 324 阅读 · 0 评论