# | 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 | 155 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
10 | nor | 152 |
Name |
---|
Firstly note that C mod X1 is less that 10^6. So now create 10^6 nodes starting from 0, 1 ... to 10^6 — 1. Now for every node add an edge for every bucket i.e for node numbered i adding an edge of bucket j means adding edge between i and (i + bucket[j]) % X1. So adding edges like this we get X1 * (number of buckets) number of edges. Now basically our problem is reaching from 0 to C mod X1. So apply djikstra's algorithm with 0 as root and find the shortest route to C mod X1. If the value of shortest path is less than C then clearly we have a solution as coefficient of X1 could be increased appropriately, otherwise there is no solution as the shortest coefficient of X1 would have to be negative which is not allowed