values and integers rounds and factor. Run rounds rounds; in each round find the smallest number in the array (the leftmost one if there are ties) and multiply it by factor.
After all the rounds, replace every number with its remainder modulo 10⁹ + 7 and return the resulting array.
There can be up to 10⁹ rounds, so simulating them one by one is too slow. Note that the remainder is taken only at the very end: during the rounds the true (huge) values are compared.values=[3, 1, 4], rounds=4, factor=3 → [9, 9, 12]
[3, 1, 4] → [3, 3, 4] → [9, 3, 4] (of the two 3s, the left one goes first) → [9, 9, 4] → [9, 9, 12]. Every number is below 10⁹ + 7, so the remainder changes nothing.
values=[500000000, 7], rounds=3, factor=10 → [500000000, 7000]
7 → 70 → 700 → 7000: after three rounds the array is [500000000, 7000], and the remainder changes nothing.
values=[1000000000, 1000000000], rounds=3, factor=2 → [999999979, 999999993]
This gives [4·10⁹, 2·10⁹]; modulo 10⁹ + 7 that is 999999979 and 999999993.
values) ≤ 10⁴values[i] ≤ 10⁹rounds ≤ 10⁹factor ≤ 10⁶values=[3, 1, 4], rounds=4, factor=3
[9, 9, 12]
Run checks the first 3 tests in your browser. Submit checks all 5 tests on the server, hidden ones included.