Cod sursa(job #68368)

Utilizator RobytzzaIonescu Robert Marius Robytzza Data 27 iunie 2007 17:37:28
Problema Patrate2 Scor 30
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.78 kb
#include<fstream.h>
#include<math.h>
int  N,a[10000],b[10000];
int main(){
ifstream fin("patrate2.in");
ofstream fout("patrate2.out");
fin>>N;
a[10000]=2;
b[10000]=a[10000];
int w=1;
for (int j=0;j<N*N;j++){
    short t=0;
    int i=10000;
 while (i>10000-w){
    a[i]+=b[i]+t;
    t=a[i]/10;
    a[i]=a[i]%10;
    b[i]=a[i];
    i--;}
if (t==1){
   a[i]=1;
   b[i]=1;
   w++;}}
long long x=1;
   for (short z=3;z<=N;z++)
       x*=z;
for (long h=0;h<x-1;h++) {
    short t=0;
    int i=10000;
while (i>10000-w){
       a[i]+=b[i]+t;
       t=a[i]/10;
       a[i]=a[i]%10;
       i--;}
if (t==1) {
   a[i]=1;
   w++;}}
int i=0;
while (a[i]==0)
   i++;
   for (int u=i;u<=10000;u++)
      fout<<a[u];
fout<<"\n";
fin.close();
fout.close();
return 0;
}