# | User | Rating |
---|---|---|
1 | tourist | 3985 |
2 | jiangly | 3814 |
3 | jqdai0815 | 3682 |
4 | Benq | 3529 |
5 | orzdevinwang | 3526 |
6 | ksun48 | 3517 |
7 | Radewoosh | 3410 |
8 | hos.lyric | 3399 |
9 | ecnerwala | 3392 |
9 | Um_nik | 3392 |
# | User | Contrib. |
---|---|---|
1 | cry | 170 |
2 | Um_nik | 162 |
3 | atcoder_official | 161 |
4 | maomao90 | 160 |
5 | djm03178 | 158 |
5 | -is-this-fft- | 158 |
7 | Dominater069 | 155 |
8 | adamant | 154 |
9 | luogu_official | 153 |
10 | awoo | 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