How can we prove this : no of unique outputs to (i*j)%k where i can be any number j and k are known is k/__gcd(k,j);
# | User | Rating |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3823 |
3 | Benq | 3738 |
4 | Radewoosh | 3633 |
5 | jqdai0815 | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | ksun48 | 3390 |
10 | gamegame | 3386 |
# | User | Contrib. |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
3 | atcoder_official | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 157 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
9 | nor | 153 |
How can we prove this : no of unique outputs to (i*j)%k where i can be any number j and k are known is k/__gcd(k,j);
Name |
---|
You need to find for which a there exists a solution to ij ≡ a (mod k) where i is a variable. Obviously if (k, j) = 1 then j has an inverse mod j so for any a < k there exists an unique solution.
Now suppose (k, j) = d! = 1, then your equation becomes equivalent to finding an l such that ij = lk + a or ij + ( - l)k = a. A pair i, l exists if and only if , so a = dx where x has some random value. Now you have d * x < k so x < k / d, so x can range from 0 to k / d - 1, so there are exactly k / d variables for which there exists a solution.