2018-10-10 18:03:03 -04:00
|
|
|
|
---
|
|
|
|
|
id: 5900f3e41000cf542c50fef7
|
2021-11-23 11:06:14 -08:00
|
|
|
|
title: '问题 120:平方余数'
|
2018-10-10 18:03:03 -04:00
|
|
|
|
challengeType: 5
|
2021-02-06 04:42:36 +00:00
|
|
|
|
forumTopicId: 301747
|
2021-01-13 03:31:00 +01:00
|
|
|
|
dashedName: problem-120-square-remainders
|
2018-10-10 18:03:03 -04:00
|
|
|
|
---
|
|
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
|
# --description--
|
2018-10-10 18:03:03 -04:00
|
|
|
|
|
2021-11-23 11:06:14 -08:00
|
|
|
|
将 `r` 记为当 ${(a − 1)}^n + {(a + 1)}^n$ 除以 $a^2$ 的余数。
|
2021-02-06 04:42:36 +00:00
|
|
|
|
|
2021-11-23 11:06:14 -08:00
|
|
|
|
例如,如果 $a = 7$ 且 $n = 3$,则 $r = 42: 6^3 + 8^3 = 728 ≡ 42 \\ \text{mod}\\ 49$。 `r` 会随着 `n` 的变化而变化,但对于 $a = 7$,会有 $r_{max} = 42$。
|
2021-02-06 04:42:36 +00:00
|
|
|
|
|
2021-11-23 11:06:14 -08:00
|
|
|
|
对于 $3 ≤ a ≤ 1000$,求 $\sum{r}_{max}$。
|
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
|
|
|
|
|
2021-11-23 11:06:14 -08:00
|
|
|
|
`squareRemainders()` 应该返回 `333082500`。
|
2018-10-10 18:03:03 -04:00
|
|
|
|
|
|
|
|
|
```js
|
2021-07-15 13:04:11 +05:30
|
|
|
|
assert.strictEqual(squareRemainders(), 333082500);
|
2018-10-10 18:03:03 -04:00
|
|
|
|
```
|
|
|
|
|
|
2021-01-13 03:31:00 +01:00
|
|
|
|
# --seed--
|
|
|
|
|
|
|
|
|
|
## --seed-contents--
|
|
|
|
|
|
|
|
|
|
```js
|
2021-07-15 13:04:11 +05:30
|
|
|
|
function squareRemainders() {
|
2021-01-13 03:31:00 +01:00
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-15 13:04:11 +05:30
|
|
|
|
squareRemainders();
|
2021-01-13 03:31:00 +01:00
|
|
|
|
```
|
|
|
|
|
|
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
|
|
|
|
|
```
|