in this problem : https://codeforces.me/contest/1295/problem/D the solution is phi(m/gcd(a,m)) why m/gcd(a,m) ????
| № | Пользователь | Рейтинг |
|---|---|---|
| 1 | Benq | 3676 |
| 2 | Kevin114514 | 3659 |
| 3 | jiangly | 3640 |
| 4 | turmax | 3450 |
| 5 | tourist | 3382 |
| 6 | strapple | 3360 |
| 7 | Um_nik | 3354 |
| 8 | squareOf105 | 3348 |
| 9 | maroonrk | 3312 |
| 10 | idontwannadothis…e | 3191 |
| Страны | Города | Организации | Всё → |
| № | Пользователь | Вклад |
|---|---|---|
| 1 | Qingyu | 158 |
| 2 | nik_exists | 151 |
| 3 | maspy | 149 |
| 4 | AmShZ | 144 |
| 5 | Um_nik | 143 |
| 6 | Errichto | 139 |
| 7 | adamant | 136 |
| 8 | BledDest | 133 |
| 9 | maroonrk | 132 |
| 10 | Proof_by_QED | 131 |
in this problem : https://codeforces.me/contest/1295/problem/D the solution is phi(m/gcd(a,m)) why m/gcd(a,m) ????
| Название |
|---|



First, think of what numbers Xi can possibly have a gcd with m that is equal to gcd(a,m). The easiest and first constraint to apply is that each Xi must be a multiple of gcd(a,m) — otherwise it wouldn't have all the necessary factors. After that, think of how we can make sure each Xi doesn't have too many factors. The first step is to divide the ok factors, gcd(a/m), out of our Xi and m. They become precisely the integers and m/gcd(a,m) respectively. Then the totient function solves.