https://mirror.codeforces.com/problemset/problem/903/A
In the tutorial, they are saying "For example, you could just iterate on the values of a and b from 0 to 33 and check if 3a + 7b = x." Why is it 33 and no other number ? Please explain it to me.
# | 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 | 166 |
2 | maomao90 | 163 |
2 | Um_nik | 163 |
4 | atcoder_official | 161 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 157 |
8 | TheScrasse | 154 |
9 | nor | 153 |
9 | Dominater069 | 153 |
https://mirror.codeforces.com/problemset/problem/903/A
In the tutorial, they are saying "For example, you could just iterate on the values of a and b from 0 to 33 and check if 3a + 7b = x." Why is it 33 and no other number ? Please explain it to me.
Name |
---|
You will never need any of a or b to be more than 33.
If a > 33, then the number of chunks these portions will contain will be 3a >= 3*34 > 100. 100 is the maximum value that you can be given, so you never want any more than 33 portions of the first type.
Similarly, if b > 14, then the number of chunks these portions will contain will be 7b >= 7*15 > 100. 100 is the maximum value that you can be given, so you never want any more than 14 portions of the second type.
But these numbers aren't really important. You just have to choose conditions for each loop. For example, you could choose a <= 33 and b <= 14.