#54911: q836程式解法


alex0607 (alex)


This program simulates a time-based battle system. It starts by reading an initial health value (hp) and two attack patterns (a and b). Each attack pattern contains a time interval and a damage value. The program then enters an infinite loop where time (x) increases by the current health value in each iteration. At every step, it checks whether the current time is a multiple of the interval in a or b. If x is divisible by a[ 0 ], the health is reduced by a[ 1 ]. Otherwise, if x is divisible by b[ 0 ], the health is reduced by b[ 1 ]. The loop continues until the health drops to zero or below. Finally, the program outputs the total time x at which the health is depleted.