Cod sursa(job #82130)

Utilizator gabitzish1Gabriel Bitis gabitzish1 Data 5 septembrie 2007 19:05:09
Problema Patrate2 Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.75 kb
#include<stdio.h>
#include<string.h>
#include<math.h>

long n[3000], rez;

void citire()
 { 
   freopen("patrate2.in","r",stdin);
   freopen("patrate2.out","w",stdout);
   scanf("%ld",&rez);
   n[0]= 1;  
 }

void inmultire(long  A[], long B)
{
      long i, t = 0;
      for (i = 1; i <= A[0] || t; i++, t /= 1000)
	      A[i] = (t += A[i] * B) % 1000;
      A[0] = i - 1;
}

int main()
{
  citire();
  long  i, x, c;

  n[0]=1; n[1]=2;
  for (i=1; i<rez*rez; i++)
     {if (i<=rez) inmultire(n,2*i);
         else inmultire(n,2);}
        

  for (i=n[0]; i>=1; i--)
    {  
	x=n[i]; c=0;
	while (x) {c++; x/=10;}
	c=3-c;
	for (int j=1; j<=c; j++) printf("0");
        printf("%ld",n[i]);
    }
     
  return 0;

}