Editorial for DMOPC '15 Contest 2 P1 - Grumpy Dwarf
Submitting an official solution before solving the problem yourself is a bannable offence.
Despite the fact that it's only the first problem, a lot of people overthought it. The intended solution is simple simulation. Keep track of the number of metal bars as well as swords we've made. Once we run out of bars, output the number of swords we've made.
bars = input() K = input() swords = 0 total = 0 while bars > 0: bars -= 1 swords += 1 total += 1 if swords == K: bars += 1 swords = 0 print total