20 Mart 2013 Çarşamba

Fourty fifth solution of Project Euler




                                                 


#include "stdafx.h"
#include <iostream>

using namespace std;

void make() {
 unsigned long tri,penta,hexa;
 bool result=false;
 do {
 for(unsigned long i=0;i<60000;i++) {
  tri = (i*(i+1))/2;
  for(unsigned long k=0;k<i;k++) {
   penta=(k*((3*k)-1))/2;
   if(tri==penta) {
    for(unsigned long l=0;l<k;l++) {
     hexa=l*((2*l)-1);
     if(penta==hexa) {
      result=true;
      if(tri>40775) {
      cout << "Problem:45\nResult :" << tri  << " efekanpulatli.blogspot.com " << endl;
      }
      break;
     }else {
      continue;
     }
    }
   }else {
    continue;
   }
  }
 }
 }while(!result);

}

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

Hiç yorum yok:

Yorum Gönder