Pagini recente » Cod sursa (job #373095) | Cod sursa (job #2598015) | Cod sursa (job #2116897) | Cod sursa (job #556501) | Cod sursa (job #42167)
Cod sursa(job #42167)
/*
*
*
info-arena 2.0 - Arhiva - Patrate2
*
*
*/
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#define INPUT "patrate2.in"
#define OUTPUT "patrate2.out"
FILE *fin=fopen(INPUT, "r"),*fout=fopen(OUTPUT, "w");
int n;
int a[10000],b[10000],c[10000];
void inmult(int x);
void inmult2(int x);
void produs();
int main()
{
memset(a,0,sizeof(a));
a[0]=1;
a[1]=1;
fscanf(fin, "%d", &n);
int h;
h=n*n;
for(int i=1;i<=h/2;++i)
inmult(4);
if(h%2!=0)
inmult(2);
b[0]=1;
b[1]=1;
for(int i=1;i<=n;++i)
inmult2(i);
produs();
for(int i=c[0];i>=1;--i)
fprintf(fout, "%d", c[i]);
fclose(fin);
fclose(fout);
return 0;
}
void inmult(int x)
{
int rest=0,temp=0,i;
for(i=1;i<=a[0];++i)
{
temp=a[i]*x+rest;
a[i]=temp%10;
rest=temp/10;
}
while(rest)
{
a[i]=rest%10;
rest/=10;
++i;
}
a[0]=i-1;
}
void inmult2(int x)
{
int rest=0,temp=0,i;
for(i=1;i<=b[0];++i)
{
temp=b[i]*x+rest;
b[i]=temp%10;
rest=temp/10;
}
while(rest)
{
b[i]=rest%10;
rest/=10;
++i;
}
b[0]=i-1;
}
void produs()
{
int rest=0,temp=0,i,j;
long poz;
memset(c,0,sizeof(c));
for(i=1;i<=a[0];++i)
{
for(j=1;j<=b[0];++j)
{
temp=c[i+j-1]+a[i]*b[j]+rest;
c[i+j-1]=temp%10;
rest=temp/10;
}
}
poz=i+j-2;
while(rest)
{
c[poz]=rest%10;
rest/=10;
++poz;
}
c[0]=poz-1;
}