2018-10-10 18:03:03 -04:00
|
|
|
|
---
|
|
|
|
|
id: 5900f3971000cf542c50feaa
|
2020-12-16 00:37:30 -07:00
|
|
|
|
title: 问题43:子串可分性
|
2018-10-10 18:03:03 -04:00
|
|
|
|
challengeType: 5
|
|
|
|
|
videoUrl: ''
|
2021-01-13 03:31:00 +01:00
|
|
|
|
dashedName: problem-43-sub-string-divisibility
|
2018-10-10 18:03:03 -04:00
|
|
|
|
---
|
|
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
|
# --description--
|
|
|
|
|
|
2020-02-18 01:40:55 +09:00
|
|
|
|
数字1406357289是0到9的全数字,因为它是由0到9的每个数字以某种顺序组成的,但是它也具有相当有趣的子字符串可除性。
|
2020-12-16 00:37:30 -07:00
|
|
|
|
|
2020-02-18 01:40:55 +09:00
|
|
|
|
令d1为第一位数,d2为第二位数,依此类推。 这样,我们注意以下几点:
|
2020-12-16 00:37:30 -07:00
|
|
|
|
|
2020-02-18 01:40:55 +09:00
|
|
|
|
d2d3d4 = 406可被2整除
|
2020-12-16 00:37:30 -07:00
|
|
|
|
|
2020-02-18 01:40:55 +09:00
|
|
|
|
d3d4d5 = 063被3整除
|
2020-12-16 00:37:30 -07:00
|
|
|
|
|
2020-02-18 01:40:55 +09:00
|
|
|
|
d4d5d6 = 635可被5整除
|
2018-10-10 18:03:03 -04:00
|
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
|
d5d6d7 = 357可被7整除
|
2018-10-10 18:03:03 -04:00
|
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
|
d6d7d8 = 572被11整除
|
2018-10-10 18:03:03 -04:00
|
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
|
d7d8d9 = 728被13整除
|
2018-10-10 18:03:03 -04:00
|
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
|
d8d9d10 = 289被17整除
|
2018-10-10 18:03:03 -04:00
|
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
|
使用此属性查找所有0到9个泛数字的数字。
|
2018-10-10 18:03:03 -04:00
|
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
|
# --hints--
|
2018-10-10 18:03:03 -04:00
|
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
|
`substringDivisibility()`应该返回[1430952867, 1460357289, 1406357289, 4130952867, 4160357289, 4106357289]。
|
2018-10-10 18:03:03 -04:00
|
|
|
|
|
|
|
|
|
```js
|
2020-12-16 00:37:30 -07:00
|
|
|
|
assert.deepEqual(substringDivisibility(), [
|
|
|
|
|
1430952867,
|
|
|
|
|
1460357289,
|
|
|
|
|
1406357289,
|
|
|
|
|
4130952867,
|
|
|
|
|
4160357289,
|
|
|
|
|
4106357289
|
|
|
|
|
]);
|
2018-10-10 18:03:03 -04:00
|
|
|
|
```
|
|
|
|
|
|
2021-01-13 03:31:00 +01:00
|
|
|
|
# --seed--
|
|
|
|
|
|
|
|
|
|
## --seed-contents--
|
|
|
|
|
|
|
|
|
|
```js
|
|
|
|
|
function substringDivisibility() {
|
|
|
|
|
|
|
|
|
|
return [];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
substringDivisibility();
|
|
|
|
|
```
|
|
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
|
# --solutions--
|
2020-08-13 17:24:35 +02:00
|
|
|
|
|
2021-01-13 03:31:00 +01:00
|
|
|
|
```js
|
|
|
|
|
// solution required
|
|
|
|
|
```
|