Hello everyone,
problem link:- https://mirror.codeforces.com/problemset/problem/1979/C
I was solving the problem and got stuck,
and in the editorial it was mentioned their that we have to use LCM I am not getting how the LCM is intuted.
what is the role of LCM...... is it observational or there is some proof for the use of LCM
please clarify about it..
you can solve it without lcm
Please can you explain the approach
You can use binary search to find the minimal outcome for the maximum k[i], which helps to determine the "number of coins returned for each possible winning outcome" -> middle. This is because it's monotonic. Once you fix the maximum value, you can use a greedy algorithm for each k[i]. For each k[i], we need to find the maximum outcome[i] such that outcome[i] * k[i] ≤ maximum(k[i]) * middle.
1st sample case: n = 3 k = {3, 2, 7}
maximum_k[i] = 7. Using binary search to find the outcome value gives us 6. (6 * 7) = 42
outcome = {14, 21, 6} —> that's the result.
ok that means I am in case of maximum we can take any other element that is also true.... thank you for your help.
Also you can check my solution
During the contest I simply guessed that lcm worked and I couldn't come up with a counter test case so I went with it
yes I think the lcm part seems quite observational.
I can see your nationality with my eyes closed
May be because of my profile picture.
Sorry sir but didn't get the context.