Redaksiya
Problem Author: | Illia Fursov, Maksym Shvedchenko, Illia Shevchenko |
Prepared by: | Illia Shevchenko, Illia Fursov |
Editorial by: | Illia Fursov |
Group 1: .
In this group, we do not need to think about the condition of having cubes of pairwise different colors, because there is at most one cube of every color. Thus, we can just check all the combinations of cubes that we can have in one set and add to the answer for every.
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c; cin >> a >> b >> c; int ans = 0; if (a and b) // blue and yellow ans += 1; if (b and c) // yellow and green ans += 1; if (a and c) // blue and green ans += 1; if (a and b and c) // blue, yellow and green ans += 1; cout << ans << endl; }
Group 2. , .
Here, the only cubes we have are of blue color. There can be at most one cube of blue color in every set, thus there can be at most one cube in every set in total. But there have to be at least two. So, the answer here is always .
Group 3. .
The only colors here are blue and yellow, and both colors have to be in every set (because there can be at most two (both) of them, and there have to be at least two of them). The number of options to choose one cube is for blue color and for yellow (because the number on a cube matters). Every combination of cubes of two colors is different, so the answer for this group is .
Group 4: (no additional constraints).
There are (at least) two ways to fully solve the problem.
The first way is the same as in the first group, but now the number of combinations are not always , but , , and for every combination of colors. So, the answer is a sum of these values: .
The other way is to count all the combinations we can do (knowing that all the cubes have to be of different colors) and exclude the ones that include only one or no cubes. For blue color there are ways to choose or not to choose a cube. The similar is for yellow and green colors, so the total number of combinations is . The number of ways to choose only one color is , and for every color correspondingly (thus, in total). The number of ways to choose none of the cubes is only one — choose to not to take a cube for every color. So, the resulting answer is , which is the same as in the first way.