Cod sursa(job #1225990)

Utilizator radudurlesteanuDurlesteanu Radu Stefan radudurlesteanu Data 4 septembrie 2014 12:02:24
Problema Lacate Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.08 kb
#include <fstream>
using namespace std;
int n,l,c,x,i,j;
ifstream fin("lacate.in");
ofstream fout("lacate.out");
bool sp;
int main()
{
fin>>n;
c=n-1;
l=c*n;
l/=2;
fout<<l<<" "<<c<<'\n';
x=1;
if (n!=2)
if (l%c!=0)
for (i=0;i<n;i++)
   {
   for (j=0;j<c;j++) {
                     fout<<x<<" ";
                     x++;
                     if (x>l) x-=l;
                     }
    fout<<'\n';
   }
   else {
        for(j=0;j<c;j++) {
                          fout<<x<<" ";
                          x++;
                          if (x>l) x-=l;
                         }
        fout<<'\n'<<"1 ";
        sp=true;
        for (i=1;i<n;i++)
            {
             for (j=0;j<c;j++) {
                                if (x==1) x++;
                                fout<<x<<" ";
                                x++;
                                if (x>l) x-=l;
                                if ((j==c-2) && (sp)) break;
                               }
             fout<<'\n';sp=false;
            }
        }
   else fout<<"1"<<'\n'<<"1"<<'\n';

}