Cod sursa(job #68341)

Utilizator RobytzzaIonescu Robert Marius Robytzza Data 27 iunie 2007 16:48:54
Problema Patrate2 Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.7 kb
#include<fstream.h>
#include<math.h>
int  N,a[2000],b[2000],i;
int main(){
ifstream fin("patrate2.in");
ofstream fout("patrate2.out");
fin>>N;
a[20]=2;
b[20]=2;
int w=1;
for (int j=0;j<N*N-1;j++){
    short t=0;
     i=2000;
while (i>2000-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++;}}
i=0;
for (long h=0;h<N-1;h++) {
    short t=0;
    i=2000;
while (i>2000-w){
       a[i]+=b[i]+t;
       t=a[i]/10;
       a[i]=a[i]%10;
       i--;}
if (t==1) {
   a[i]=1;
   w++;}}
i=0;
while (a[i]==0)
   i++;
   for (int u=i;u<=2000;u++)
      fout<<a[u];
fout<<"\n";
fin.close();
fout.close();
return 0;
}