Edward Lu


Note the constraint 1≤a[i][j]≤16, this is special

I tried using brute force way to fill in the answer array.

But it is too slow.

It just seems hard/slow to brute force an answer.

Instead, we can look into this:

If we colour the board into chess board. We can observe that, black cells only adjacent to white cells.

If we change all black cells to LCM(1,2,…,16) and white cells to LCM(1,2,…,16)+a[i][j]⁴

We are done.