Dice Sum
InterviewTime limit2sMemory limit128 MB
Given three dice with sizes S1, S2, S3, find the sum value that occurs most often among all possible triples, choosing the smallest if tied.
- Level
Easy3 of 10
- Topics
- Brute force, Math, Simulation
- Solved
- No attempts yet
Problem
Three special dice are rolled at the same time. The first die has faces numbered from 1 to S1, the second die has faces numbered from 1 to S2, and the third die has faces numbered from 1 to S3.
For every possible triple of rolled values (a, b, c), count how often each sum a + b + c appears. Print the sum that appears most often. If several sums appear equally often, print the smallest such sum.
Input
The first line contains three integers S1, S2, and S3, separated by spaces.
2 <= S1 <= 202 <= S2 <= 202 <= S3 <= 40
Output
Print the most frequent sum of the three dice. If there is more than one answer, print the smallest sum among them.