CF1266C Diverse Matrix

题目描述

对于一个r行c列的矩阵,我们可以求出它每一行,每一列的最大公约数(共r+c个数)。 输入r,c。要求输出一个矩阵,满足这r+c个数不同,且这r+c个数的最大值最小。

输入格式

输入一行两个整数,分别为r,c。(1≤r,c≤500)

输出格式

如果无解输出0,否则输出你构造的r行c列的矩阵,要求矩阵中的每个元素满足1≤a≤1e9 。

说明/提示

In the first example, the GCDs of rows are $ b_1 = 4 $ and $ b_2 = 1 $ , and the GCDs of columns are $ b_3 = 2 $ and $ b_4 = 3 $ . All GCDs are pairwise distinct and the maximum of them is $ 4 $ . Since the GCDs have to be distinct and at least $ 1 $ , it is clear that there are no diverse matrices of size $ 2 \times 2 $ with magnitude smaller than $ 4 $ . In the second example, no matter what $ a_{1,1} $ is, $ b_1 = b_2 $ will always hold, so there are no diverse matrices.