8 Mart 2013 Cuma

Twenty fifth solution of Project Euler






#include "stdafx.h"
#include <iostream>
using namespace std;

void findout () {
int x,a[1011],b[1011],tot[1011];
for(int i=0;i<1010;i++) {             //dizilerin elemanlarına 0 koy
a[i] = 0;
b[i] = 0;
tot[i] = 0;
}
a[1009]=1;
a[1010]=3;
b[1009]=2;
b[1010]=1;
for(x=0;x<8888;x++) {
for(int i=1010;i>=0;i--) {
if(a[i] + b[i] <10){
        tot[i] = a[i] + b[i];
}else {   //elde varsa
tot[i] = (a[i] + b[i]) % 10;
a[i-1]+=1;


}
a[i]=b[i];
b[i]=tot[i];
}
if(tot[11]!=0) {
cout << x+9 << " efekanpulatli.blogspot.com" << endl;
break;

}
}

}

int main() {
findout();
system("pause");
return 0;
}

Hiç yorum yok:

Yorum Gönder