Cod sursa(job #3331294)

Utilizator mateilupuMatei Lupu mateilupu Data 26 decembrie 2025 14:28:39
Problema Tablete Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.78 kb
#include <fstream>

using namespace std;

int a[1001][1001];

int main()
{
    ifstream cin ("tablete.in");
    ofstream cout ("tablete.out");
    int n, k, i, j, x = 0;
    bool ok = 0;
    cin >> n >> k;
    for(i = 1; i <= n; i++) {
        for(j = 1; j <= k; j++) {
            x++;
            a[i][j] = x - ok;
            ok = 0;
            if(j == k && x % 2 == 1) {
                a[i][j]++;
                ok = 1;
            }
        }
    }
    for(i = 1; i <= n; i++) {
        for(j = k + 1; j <= n; j++) {
            x++;
            a[i][j] = x - ok;
            ok = 0;
        }
    }
    for(i = 1; i <= n; i++) {
        for(j = 1; j <= n; j++) {
            cout << a[i][j] << " ";
        }
        cout << '\n';
    }
    return 0;
}