Cod sursa(job #3150764)

Utilizator gicaviitorulgica viitorul gicaviitorul Data 18 septembrie 2023 11:37:32
Problema Tablete Scor 10
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.91 kb

#include <bits/stdc++.h>

using namespace std;
ifstream fin("tablete.in");
ofstream fout("tablete.out");
const int nmax=1e6+1;
bool vf[nmax];
int main()
{
    int n,k;
    fin>>n>>k;
    for(int i=1;i<=n;++i){
        for(int j=1;j<=n;++j){
           for(int l=1;l<=nmax;++l){
                if(!vf[l] && j!=k){
                    fout<<l<<" ";
                    vf[l]=1;
                    break;
                }else if(!vf[l] && j==k){
                    if(l%2==0){
                        fout<<l<<" ";
                        vf[l]=1;
                    }else{
                        vf[l]=1;
                        l++;
                        fout<<l<<" ";
                        vf[l]=1;
                    }
                    break;
                   
                }
                //break;
            }
        }
        fout<<endl;
    }

    return 0;
}