Codeforce Round #210 Div2 A
Levko loves tables that consist of n rows and n columns very much. He especially loves beautiful tables. A table is beautiful to Levko if the sum of elements in each row and column of the table equals k.
Unfortunately, he doesn't know any such table. Your task is to help him to find at least one of them.
The single line contains two integers, n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 1000).
Print any beautiful table. Levko doesn't like too big numbers, so all elements of the table mustn't exceed 1000 in their absolute value.
If there are multiple suitable tables, you are allowed to print any of them.
2 4
1 3 3 1
4 7
2 1 0 4 4 0 2 1 1 3 3 0 0 3 2 2
In the first sample the sum in the first row is 1 + 3 = 4, in the second row — 3 + 1 = 4, in the first column — 1 + 3 = 4 and in the second column — 3 + 1 = 4. There are other beautiful tables for this sample.
In the second sample the sum of elements in each row and each column equals 7. Besides, there are other tables that meet the statement requirements.
1 #pragma comment(linker, "/STACK:1024000000,1024000000") 2 #include <map> 3 #include <stack> 4 #include <queue> 5 #include <vector> 6 #include <string> 7 #include <cmath> 8 #include <cstdio> 9 #include <cstring> 10 #include <cstdlib> 11 #include <iostream> 12 #include <algorithm> 13 using namespace std; 14 #define maxn 10055 15 #define ll long long 16 #define mod 1000000007 17 #define INF 0x7fffffff 18 #define eps 1e-8 19 int n, m, k, sx, sy; 20 int a[maxn]; 21 int main(){ 22 int t; 23 //scanf("%d", &t); 24 //while (t--){ 25 //memset(a, 0, sizeof a); 26 //memset(b, 0, sizeof b); 27 scanf("%d%d", &n, &m); 28 for (int i = 0; i < n; i++){ 29 for (int j = 0; j < n; j++){ 30 if (i == j)printf("%d ", m); 31 else printf("0 "); 32 } 33 printf("\n"); 34 } 35 //} 36 return 0; 37 }
浙公网安备 33010602011771号