2018-10-10 22:03:03 +00:00
|
|
|
|
---
|
|
|
|
|
id: 5900f3901000cf542c50fea3
|
|
|
|
|
challengeType: 5
|
|
|
|
|
videoUrl: ''
|
2020-10-01 15:54:21 +00:00
|
|
|
|
title: 问题36:双基回文
|
2018-10-10 22:03:03 +00:00
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
## Description
|
|
|
|
|
<section id="description">十进制数,585 = 10010010012(二进制),在两个碱基中都是回文。找到所有数字的总和,小于n,而1000 <= n <= 1000000,它们在基数10和基数2中是回文的。(请注意,任一基数中的回文数可能不包括前导零。) </section>
|
|
|
|
|
|
|
|
|
|
## Instructions
|
|
|
|
|
<section id="instructions">
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
## Tests
|
|
|
|
|
<section id='tests'>
|
|
|
|
|
|
|
|
|
|
```yml
|
|
|
|
|
tests:
|
|
|
|
|
- text: <code>doubleBasePalindromes(1000)</code>应该返回1772。
|
2020-02-17 16:40:55 +00:00
|
|
|
|
testString: assert(doubleBasePalindromes(1000) == 1772);
|
2018-10-10 22:03:03 +00:00
|
|
|
|
- text: <code>doubleBasePalindromes(50000)</code>应该返回105795。
|
2020-02-17 16:40:55 +00:00
|
|
|
|
testString: assert(doubleBasePalindromes(50000) == 105795);
|
2018-10-10 22:03:03 +00:00
|
|
|
|
- text: <code>doubleBasePalindromes(500000)</code>应该返回286602。
|
2020-02-17 16:40:55 +00:00
|
|
|
|
testString: assert(doubleBasePalindromes(500000) == 286602);
|
2018-10-10 22:03:03 +00:00
|
|
|
|
- text: <code>doubleBasePalindromes(1000000)</code>应该返回872187。
|
2020-02-17 16:40:55 +00:00
|
|
|
|
testString: assert(doubleBasePalindromes(1000000) == 872187);
|
2018-10-10 22:03:03 +00:00
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
## Challenge Seed
|
|
|
|
|
<section id='challengeSeed'>
|
|
|
|
|
|
|
|
|
|
<div id='js-seed'>
|
|
|
|
|
|
|
|
|
|
```js
|
|
|
|
|
function doubleBasePalindromes(n) {
|
|
|
|
|
// Good luck!
|
|
|
|
|
return n;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
doubleBasePalindromes(1000000);
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
## Solution
|
|
|
|
|
<section id='solution'>
|
|
|
|
|
|
|
|
|
|
```js
|
|
|
|
|
// solution required
|
|
|
|
|
```
|
2020-08-13 15:24:35 +00:00
|
|
|
|
|
|
|
|
|
/section>
|