# | 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 |
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