Pagini recente » Cod sursa (job #2990741) | Cod sursa (job #1108614) | Cod sursa (job #1239364) | Cod sursa (job #2956310) | Cod sursa (job #2488678)
#include <bits/stdc++.h>
FILE *in = fopen("lacate.in", "r"), *out = fopen("lacate.out", "w") ;
int mat[300][300] ;
void build(int lin, int col) {
if (lin == 2 && col == 1) {
mat[1][1] = 1 ;
mat[2][1] = 1 ;
return ;
}
build(lin - 1, col - 1) ;
int now = ((lin - 2) * (lin - 1) / 2) + 1 ;
for (int i = 1 ; i <= lin - 1 ; ++ i) {
mat[i][col] = now ++ ;
}
now = ((lin - 2) * (lin - 1) / 2) + 1 ;
for (int i = 1 ; i <= col ; ++ i) {
mat[lin][i] = now ++ ;
}
}
int main() {
int n ;
fscanf(in, "%d", &n) ;
int lin = n ;
int col = n - 1 ;
fprintf(out, "%d %d\n", lin * col / 2, col) ;
build(lin, col) ;
for (int i = 1 ; i <= lin ; ++ i) {
for (int j = 1 ; j <= col ; ++ j) {
fprintf(out, "%d ", mat[i][j]) ;
}
fputc('\n', out) ;
}
}