题目描述
编写一个程序判断给定的数是否为丑数。
丑数就是只包含质因数 2, 3, 5
的正整数。
示例 1:
1 | 输入: 6 |
示例 2:
1 | 输入: 8 |
示例 3:
1 | 输入: 14 |
说明:
1
是丑数。- 输入不会超过 32 位有符号整数的范围: $[−2^{31}, 2^{31}-1]$。
Sherlock Holmes received a note with some strange strings: Let's date! 3485djDkxh4hhGE 2984akDfkkkkggEdsb s&hgsfdk d&Hyscvnm
. It took him only a minute to figure out that those strange strings are actually referring to the coded time Thursday 14:04
– since the first common capital English letter (case sensitive) shared by the first two strings is the 4th capital letter D
, representing the 4th day in a week; the second common character is the 5th capital letter E
, representing the 14th hour (hence the hours from 0 to 23 in a day are represented by the numbers from 0 to 9 and the capital letters from A
to N
, respectively); and the English letter shared by the last two strings is s
at the 4th position, representing the 4th minute. Now given two pairs of strings, you are supposed to help Sherlock decode the dating time.
大侦探福尔摩斯接到一张奇怪的字条:我们约会吧! 3485djDkxh4hhGE 2984akDfkkkkggEdsb s&hgsfdk d&Hyscvnm
。大侦探很快就明白了,字条上奇怪的乱码实际上就是约会的时间星期四 14:04
,因为前面两字符串中第 1 对相同的大写英文字母(大小写有区分)是第 4 个字母 D
,代表星期四;第 2 对相同的字符是 E
,那是第 5 个英文字母,代表一天里的第 14 个钟头(于是一天的 0 点到 23 点由数字 0 到 9、以及大写字母 A
到 N
表示);后面两字符串第 1 对相同的英文字母 s
出现在第 4 个位置(从 0 开始计数)上,代表第 4 分钟。现给定两对字符串,请帮助福尔摩斯解码得到约会的时间。
一个合法的身份证号码由17位地区、日期编号和顺序编号加1位校验码组成。校验码的计算规则如下:
首先对前17位数字加权求和,权重分配为:{7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2};然后将计算的和对11取模得到值Z
;最后按照以下关系对应Z
值与校验码M
的值:
1 | Z:0 1 2 3 4 5 6 7 8 9 10 |
现在给定一些身份证号码,请你验证校验码的有效性,并输出有问题的号码。
给定一个 k 位整数 N=$d_{k−1} 10^{k−1}+⋯+d_1 10^1+d_0 (0≤d_i≤9, i=0,⋯,k−1, d_{k−1}>0)$,请编写程序统计每种不同的个位数字出现的次数。例如:给定 N=100311,则有 2 个 0,3 个 1,和 1 个 3。
让我们用字母 B
来表示“百”、字母 S
表示“十”,用 12...n
来表示不为零的个位数字 n
(<10),换个格式来输出任一个不超过 3 位的正整数。例如 234
应该被输出为 BBSSS1234
,因为它有 2 个“百”、3 个“十”、以及个位的 4。
在 O(n log n) 时间复杂度和常数级空间复杂度下,对链表进行排序。
示例 1:
1 | 输入: 4->2->1->3 |
示例 2:
1 | 输入: -1->5->3->4->0 |