atcoder#AGC061D. [AGC061D] Almost Multiplication Table
[AGC061D] Almost Multiplication Table
Score : points
Problem Statement
There are positive integers , and an positive integer matrix . For two (strictly) increasing positive integer sequences and , we define the penalty as $\max_{1 \leq i \leq N, 1 \leq j \leq M} |X_i Y_j - A_{i, j}|$.
Find two (strictly) increasing positive integer sequences and such that is the smallest possible.
Constraints
- (, )
- All values in the input are integers.
Input
Input is given from Standard Input in the following format:
Output
Output your answer in the following format:
Here, is the smallest possible penalty and the following conditions should be satisfied:
- should be equal to .
- ().
- ().
- ().
- ().
One can show that there is an optimal solution satisfying the last two conditions.
1 1
853922530
0
31415
27182
3 3
4 4 4
4 4 4
4 4 4
5
1 2 3
1 2 3
3 4
4674 7356 86312 100327
8737 11831 145034 167690
47432 66105 809393 936462
357
129 216 1208
39 55 670 775