You're a professional hacker and your boss has just ordered you to help a candidate win an upcoming election. Your task is to alter the voting machines data to boost the candidate's results.
Voting machines store voting results as two integers : the number of votes for your candidate (
v1) and the number of votes for their opponent (
After weeks of research, you have found a security hole in the system and you can increase the value of
v1 by an integer
x, and decrease the value of
v2 by the same
But there is a constraint, you have to keep the security hash code constant:
- security hash code :
(v1 + v2*2) modulo 7
Also, the value for
x must be minimal so your changes can go unnoticed.
Your program should accept as input
v2 ; it should output the optimal value for
There are some cases for which you cannot hack the results; you don't have to handle them (this might lead to problems with your boss, but that's another story).
100,123 --> 14 47,23 --> 0 40,80 --> 21 62,62 --> 7 1134,2145 --> 511