2021-06-15 00:49:18 -07:00
|
|
|
---
|
|
|
|
id: 5900f4b21000cf542c50ffc5
|
2022-03-01 21:39:26 +05:30
|
|
|
title: 'Problema 326: sommatoria dei moduli'
|
2021-06-15 00:49:18 -07:00
|
|
|
challengeType: 5
|
|
|
|
forumTopicId: 301983
|
|
|
|
dashedName: problem-326-modulo-summations
|
|
|
|
---
|
|
|
|
|
|
|
|
# --description--
|
|
|
|
|
2022-03-01 21:39:26 +05:30
|
|
|
Sia $a_n$ una sequenza definita ricorsivamente da: $a_1 = 1$, $\displaystyle a_n = \left(\sum_{k = 1}^{n - 1} k \times a_k\right)\bmod n$.
|
2021-06-15 00:49:18 -07:00
|
|
|
|
2022-03-01 21:39:26 +05:30
|
|
|
Quindi i primi 10 elementi di $a_n$ sono: 1, 1, 0, 3, 0, 3, 5, 4, 1, 9.
|
2021-06-15 00:49:18 -07:00
|
|
|
|
2022-03-01 21:39:26 +05:30
|
|
|
Lascia che $f(N, M)$ rappresenti il numero di coppie $(p, q)$ tali che:
|
2021-06-15 00:49:18 -07:00
|
|
|
|
2022-03-01 21:39:26 +05:30
|
|
|
$$ 1 \le p \le q \le N \\; \text{and} \\; \left(\sum_{i = p}^q a_i\right)\bmod M = 0$$
|
2021-06-15 00:49:18 -07:00
|
|
|
|
2022-03-01 21:39:26 +05:30
|
|
|
Si può vedere che $f(10, 10) = 4$ con le coppie (3,3), (5,5), (7,9) e (9,10).
|
2021-06-15 00:49:18 -07:00
|
|
|
|
2022-03-01 21:39:26 +05:30
|
|
|
Ti viene anche dato che $f({10}^4, {10}^3) = 97\\,158$.
|
|
|
|
|
|
|
|
Trova $f({10}^{12}, {10}^6)$.
|
2021-06-15 00:49:18 -07:00
|
|
|
|
|
|
|
# --hints--
|
|
|
|
|
2022-03-01 21:39:26 +05:30
|
|
|
`moduloSummations()` dovrebbe restituire `1966666166408794400`.
|
2021-06-15 00:49:18 -07:00
|
|
|
|
|
|
|
```js
|
2022-03-01 21:39:26 +05:30
|
|
|
assert.strictEqual(moduloSummations(), 1966666166408794400);
|
2021-06-15 00:49:18 -07:00
|
|
|
```
|
|
|
|
|
|
|
|
# --seed--
|
|
|
|
|
|
|
|
## --seed-contents--
|
|
|
|
|
|
|
|
```js
|
2022-03-01 21:39:26 +05:30
|
|
|
function moduloSummations() {
|
2021-06-15 00:49:18 -07:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2022-03-01 21:39:26 +05:30
|
|
|
moduloSummations();
|
2021-06-15 00:49:18 -07:00
|
|
|
```
|
|
|
|
|
|
|
|
# --solutions--
|
|
|
|
|
|
|
|
```js
|
|
|
|
// solution required
|
|
|
|
```
|