Блог пользователя lofy234234

Автор lofy234234, история, 4 года назад, По-английски

in this problem : https://codeforces.me/contest/1295/problem/D the solution is phi(m/gcd(a,m)) why m/gcd(a,m) ????

  • Проголосовать: нравится
  • +1
  • Проголосовать: не нравится

»
4 года назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

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.