lots[i] is the number of units in lot i. There are also pack types: pack j holds packs[j] units, and packs ship in blocks of factor, so a block of type j is packs[j] · factor units.
A pair (i, j) fits if lot lots[i] can be split entirely into blocks of type j with nothing left over. Return the number of fitting pairs. Pairs with different indices count separately even when their numbers are equal.
The arrays can be long, so checking every pair will be too slow.lots=[12, 18, 7], packs=[2, 3, 6], factor=2 → 4
Blocks hold 4, 6 and 12 items. Lot 12 splits into blocks of 4, 6 or 12, lot 18 only into blocks of 6, and 7 into none: 3 + 1 = 4 pairs.
lots=[5, 5], packs=[1, 1], factor=5 → 4
Each of the two lots splits into blocks of 5 for each of the two packs: 2 · 2 = 4 pairs.
lots=[9], packs=[2], factor=3 → 0
A block of 6 does not divide a lot of 9.
lots), len(packs) ≤ 10⁵lots[i], packs[j] ≤ 10⁶factor ≤ 1000lots=[12, 18, 7], packs=[2, 3, 6], factor=2
4
Run checks the first 3 tests in your browser. Submit checks all 86 tests on the server, hidden ones included.