Here is the Link of the topcoder problem Link i read its editorial but not able to get it would anyone like to help me to understand this ??
№ | Пользователь | Рейтинг |
---|---|---|
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 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
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 |
Here is the Link of the topcoder problem Link i read its editorial but not able to get it would anyone like to help me to understand this ??
Название |
---|
Take it like this:
There must be a 1-coin. Suppose you took k 1-coins, then you can't make k + 1 in any way other than by one k + 1-coin. Now, you have ways to make all values up to 2k + 1. Suppose you took l k + 1-coins. Then you can make all values up to l(k + 1) + k, each exactly once. Again, you need a coin with cost l(k + 1) + k + 1 = (l + 1)(k + 1) to achieve the next value. That looks suspicious: in fact, if you have xi coins of the i-th type, the next coin must have value .
That means if we sorted the coin types that we take at least 1 coin into a sequence of xi, then xi - 1 divides xi and there must be coins of type i - 1; the number of coins of the last type can be chosen easily based on the fact that if it's k, then we can make all values up to kxn - 1.
And now that we know how many coins to use, we can do a DP on the total number of coins used for types starting with the i-th, in O(N2). I leave that up to you.
thanx Xellos
TopCoder SRM 195 Div 2, Level Three, ChangePurse, Advanced Math. (written for bare purpose of web crawlers to index the page and associate it with related query. wish it was done by tags and headers)