Cod sursa(job #193932)

Utilizator alexeiIacob Radu alexei Data 7 iunie 2008 17:59:20
Problema Lacate Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.69 kb
#include<stdio.h>
#define nmax 270

int a[nmax][nmax];

int main()
{
 freopen("lacate.in","r",stdin);
 freopen("lacate.out","w",stdout);
                                    
 int N,M;
 
 scanf("%d",&N);
 
 M=N-1;
 
 int C=1,j,i;
 
 a[1][1]=1;
 
 for(i=2,j=2; i<=M; ++i,++j)
 C=C+N-j+1,
 a[i][j]=C;
 
 printf("%d %d\n",C,M);
 
 int k,p,aux;
 
 for(i=1,j=1; j<=M; ++i,++j)
 {
 aux=a[i][j]+1;

          for( k=j+1; k<=M; ++k )
          a[i][k]=aux++;
          
 aux=a[i][j];
 
          for( p=i+1; p<=N; ++p )        
          a[p][j]=aux++;
 }
 
 for(i=1; i<=N; ++i){
  for(j=1; j<=M; ++j)
  printf("%d ",a[i][j]);
 printf("\n");
 }
    
    return 0;
}