Cod sursa(job #252616)
Utilizator | Data | 4 februarie 2009 18:32:42 | |
---|---|---|---|
Problema | Nunta | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.46 kb |
#include<stdio.h>
#define NMAX 1001
unsigned long c[NMAX][NMAX],n;
int main()
{
int i,j;
unsigned long s=0;
freopen("nunta.in","r",stdin);
freopen("nunta.out","w",stdout);
scanf("%d",&n);
c[1][1]=c[1][2]=1;
for(i=2;i<=n;i++)
for(j=1;j<=i+1;j++)
c[i][j]=c[i-1][j-1]+c[i-1][j];
for(i=2;i<=n;i++)
{ printf("%d",i);for(j=1;j<=i+1;j++)
printf("%2d ",c[i][j]);
printf("\n");
}
for(i=n;i>=(n+1)/2;i--)
s+=c[i][n-i+1];
printf("%ld",s);
return 0;
}