# | User | Rating |
---|---|---|
1 | tourist | 3993 |
2 | jiangly | 3743 |
3 | orzdevinwang | 3707 |
4 | Radewoosh | 3627 |
5 | jqdai0815 | 3620 |
6 | Benq | 3564 |
7 | Kevin114514 | 3443 |
8 | ksun48 | 3434 |
9 | Rewinding | 3397 |
10 | Um_nik | 3396 |
# | 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 | 156 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
10 | nor | 152 |
Name |
---|
For Problem B Large:
We need to make use of the property:
i^a % k = (i + k)^a % k
So e.g.,
2^5 % 7 = (2 + 7)^5 % 7 = (2 + 2*7)^5 % 7 = (2 + 3*7)^5 % 7 = ...
and so on.So we only need to iterate from 1 till k.
So iterate from 1 to k and find all the modulo the respective numbers give with A and B. Store the count of numbers in an array, where index is the modulo and value is the total numbers who give that modulo. Then finally iterate over the array and for all
i
find the value ofk - i
index and these will be the pair count we are looking for. To exclude same numbers as specified in the problem, use a map or something similar which maintains the record of how many same numbers could possibly contribute to the final answer. Subtract them.I think you need to use dynamic programming, for problem C.
My code for Problem C, small — http://ideone.com/bxHN0y