2021-05-05 10:13:49 -07:00
|
|
|
|
---
|
|
|
|
|
id: 5900f3fd1000cf542c50ff10
|
2021-11-17 03:53:39 -08:00
|
|
|
|
title: '問題 145:有多少個小於十億的可逆數?'
|
2021-05-05 10:13:49 -07:00
|
|
|
|
challengeType: 5
|
|
|
|
|
forumTopicId: 301774
|
|
|
|
|
dashedName: problem-145-how-many-reversible-numbers-are-there-below-one-billion
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
# --description--
|
|
|
|
|
|
2021-11-17 03:53:39 -08:00
|
|
|
|
一些正整數 $n$ 滿足如下性質:該數與其逆序數之和 [ $n + reverse(n)$ ] 全部由奇數(十進制)組成。 例如,$36 + 63 = 99$ 和 $409 + 904 = 1313$。 我們稱這些數字是可逆的;所以 36、63、409 和 904 均爲可逆的。 無論是 $n$ 還是 $reverse(n)$ 均不允許出現前導零。
|
2021-05-05 10:13:49 -07:00
|
|
|
|
|
2021-11-17 03:53:39 -08:00
|
|
|
|
小於一千的可逆數有 120 個。
|
2021-05-05 10:13:49 -07:00
|
|
|
|
|
2021-11-17 03:53:39 -08:00
|
|
|
|
請求出有多少個小於十億(${10}^9$)的可逆數?
|
2021-05-05 10:13:49 -07:00
|
|
|
|
|
|
|
|
|
# --hints--
|
|
|
|
|
|
2021-11-17 03:53:39 -08:00
|
|
|
|
`reversibleNumbers()` 應該返回 `608720`。
|
2021-05-05 10:13:49 -07:00
|
|
|
|
|
|
|
|
|
```js
|
2021-11-17 03:53:39 -08:00
|
|
|
|
assert.strictEqual(reversibleNumbers(), 608720);
|
2021-05-05 10:13:49 -07:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
# --seed--
|
|
|
|
|
|
|
|
|
|
## --seed-contents--
|
|
|
|
|
|
|
|
|
|
```js
|
2021-11-17 03:53:39 -08:00
|
|
|
|
function reversibleNumbers() {
|
2021-05-05 10:13:49 -07:00
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-17 03:53:39 -08:00
|
|
|
|
reversibleNumbers();
|
2021-05-05 10:13:49 -07:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
# --solutions--
|
|
|
|
|
|
|
|
|
|
```js
|
|
|
|
|
// solution required
|
|
|
|
|
```
|