https://codeforces.net/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 | 3985 |
2 | jiangly | 3741 |
3 | jqdai0815 | 3682 |
4 | Benq | 3529 |
5 | orzdevinwang | 3526 |
6 | ksun48 | 3489 |
7 | Radewoosh | 3483 |
8 | Kevin114514 | 3442 |
9 | ecnerwala | 3392 |
9 | Um_nik | 3392 |
# | User | Contrib. |
---|---|---|
1 | cry | 169 |
2 | atcoder_official | 162 |
2 | maomao90 | 162 |
2 | Um_nik | 162 |
5 | djm03178 | 158 |
6 | -is-this-fft- | 157 |
7 | adamant | 155 |
8 | awoo | 154 |
8 | Dominater069 | 154 |
10 | nor | 150 |
https://codeforces.net/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.