16 Şubat 2013 Cumartesi

Codeforces - Beatiful Year


                                                                Click and See Problem



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

void findout () {
int a,b=0,digon,digtw,digth,digfo;
bool c=false;
do {
cout << "Please Enter Bigger than 1000 and Smaller than 9000" << endl;
cin >> a;
}while(a<1000 || a > 9000);

do {
a++;
   digon = a/1000;
digtw = (a - (digon* 1000)) / 100;
digth = (a % 100) / 10;
   digfo = a %10;

if(digon == digtw || digon == digth || digon ==digfo || digtw == digth ||digtw == digfo || digth == digfo ) {

c = false;

}else {
          c=true;
}


}while(c==false);
cout <<a << " efekanpulatli.blogspot.com" << endl;
}


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

9 Şubat 2013 Cumartesi

Third solution of Project Euler




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

int asalmi(unsigned long long x) {
unsigned long long x2=2,x3=0;
for(;x2<x;x2++) {
if(x % x2 == 0) {
x3++;
break;
};
}


if(x3 == 0) {
x3=1;
return x3;
} else {
x3=0;
return x3;
}

}

void findout() {
unsigned long long i=9851475143;         // think why I shortened i ?
for(;i>0;i--) {
if(600851475143% i == 0 && asalmi(i) == 1) {
break;
}
}
cout << "Result :" << i << " efekanpulatli.blogspot.com" << endl;
}

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

Twenty-first solution of Project Euler






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

void findout () {
int a,b,c,dizi[2][10001];
unsigned long long result=0;
for(a=1;a<10000;a++) {
dizi[0][a]=0;
for(b=1;b<a;b++) {
if(a%b==0) {
dizi[0][a]+=b;
                dizi[1][a] =a;
}
}
}

for(a=1;a<10000;a++) {

for(b=1;b<10000;b++) {
if(a == dizi[0][b] && b == dizi[0][a] && a!=b) {
int d = dizi[1][a] + dizi[1][b];
result+=d;
cout << a <<  "       toplamlari" << dizi[0][a]<<  "      "<< b  << "   toplamlari     " << dizi[0][b] << endl;

}
}
}

cout << result/2 << " efekanpulatli.blogspot.com " << endl;
}


int main() {

findout();
system("pause");
return 0;
}

8 Şubat 2013 Cuma

Twelfth solution of Project Euler






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

void findout () {
int a,b,c,dizi[20000],d;
for(a=1;a<20000;a++) {                //sayilari diziye atıyoruz
dizi[a] = (a * (a+1)) / 2;
}
           for(b=9999;b<15000;b++) {
  d=0;
  for(c=1;c<=dizi[b];c++) {
  if(dizi[b] %c == 0) {
  d++;
  }
 
  }
   
  if(d>500) {
  cout << dizi[b] <<  " efekanpulatli.blogspot.com" << endl;
  break;
  }

  }
}


int main() {

findout();
system("pause");
return 0;
}

7 Şubat 2013 Perşembe

Sixteenth solution of Project Euler






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


void findout() {
int dizi[1001] = {1},a,elde=0;
for(int i=1;i<1001;i++) {
           for(a=0;a<1001;a++) {

  if((dizi[a] * 2) < 10) {     // elde gelmiyorsa
  dizi[a] = ((dizi[a] * 2 ) + elde) % 10;
  elde=0;
  }else {
  if(dizi[a+1] ==0) {
 dizi [a] = ((dizi[a] * 2) + elde)%10;
 dizi[a+1] = 1;
 a++;
 elde = 0;
  }else {
  dizi[a] = ((dizi[a] * 2) +elde) % 10;
  elde = 1;
  }

  }
  }

}
int tot=0;
for(int i=0;i<400;i++) {
tot+=dizi[i] ;
}
cout << tot << " efekanpulatli.blogspot.com" << endl;
}
int main()
{
findout();
system("pause");
return 0;
}

6 Şubat 2013 Çarşamba

Fourteenth solution of Project Euler





#include "stdafx.h"
#include <iostream>
using namespace std;
void findout() {
unsigned long long c=1,c2=0,a,b,result;
for(a=1;a<1000000;a++) {
b=a;
c=1;
do {
if(b % 2 == 1) {   // if b is odd (eger b tekse)
b=((b*3) + 1);
c++;
}else {                 // if not (degilse)
b/=2;
c++;
}
}while(b!=1);
if(c>c2) {
c2=c;
result = a;
}
}
cout << "Sonuc :" << result << " efekanpulatli.blogspot.com" << endl;
}
int main()
{
findout();
system("pause");
return 0;
}

Tenth solution of Project Euler





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



void findout() {
int a,b,c;
unsigned long long tot=0;
  for(a=2;a<2000000;a++) {
 c=0;
 for(b=2;b<a;b++) {
 if(a%b == 0) {
 c++;
 break;}



 }
  if(c==0) {
 tot+=a;

 }

  }

     cout << tot<< " efekanpulatli.blogspot.com " << endl;



}

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

Nineth solution of Project Euler






#include "stdafx.h"
#include <iostream>
using namespace std;
void findout() {    
     int a,b,c;
for(a=5;a<1000;a++) {
for(b=4;b<a;b++) {
for(c=3;c<b;c++) {
if((a+b+c) == 1000 && ((c*c) + (b*b)) == (a*a)) {
cout << "Sonuc :" << a * b * c << endl << "Sayilar : " << a << "," << b << "," << c << endl;
cout << "efekanpulatli.blogspot.com" << endl;
}

}
}
}

 }

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

Seventh solution of Project Euler







#include "stdafx.h"
#include <iostream>
using namespace std;
void findout() {       // let's begin find out 10001 prime number
   int a,c=0,dizi[10002],d=0;
           for(a=1;d<10002;a++){
c=0;
for(int i=2;i<a;i++) {
if(a%i==0) {
c++;
}
}
if(c==0) {
dizi[d] = a;
d++;
}
}
cout << "10001.Prime Number : " << dizi[10001] << " efekanpulatli.blogspot.com" << endl;
}

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

Sixth solution of Project Euler


   


#include "stdafx.h"
#include <iostream>
using namespace std;  
void findout() {  
      int a,b=0,c=0;

for(a=1;a<101;a++) {
b+=a;
c+=(a*a);
}
       b*=b;
  cout << "Result :" << b-c << " efekanpulatli.blogspot.com" << endl;
}

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

Fifth solution of Project Euler








#include "stdafx.h"
#include <iostream>
using namespace std;  
void findout() {  
int c=0,i=10000;
for(;;i++) {
c=0;
for(int a=1;a<21;a++) {

if(i%a!=0) {
c++;
};
}
if(c==0) {
break;
}
}
cout << "Sonuc :" << i  << " efekanpulatli.blogspot.com" << endl;
}

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

5 Şubat 2013 Salı

Fourth solution of Project Euler







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

void findout() {
int a,b,x,c=1,y,z;
for(a=999;a>=100;a--) {
for(b=999;b>=100;b--) {
x = a*b;
if((x/100000) == (x % 10) && ((x/10000) % 10) == ((x%100) / 10) && ((x/1000) %10) == ((x%1000) / 100) && x>c) {
c=x;
y=a;
z=b;
}
}
if((x/100000) == (x % 10) && ((x/10000) % 10) == ((x%100) / 10) && ((x/1000) %10) == ((x%1000) / 100) && x>c) {
c=x;
y=a;
z=b;
}

}
cout << "Cevap :" << c << "  sayilar :" << y << " ve " << z <<  "   efekanpulatli.blogspot.com" <<   endl;
}

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

Second solution of Project Euler






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

void findout() {                  //efekanpulatli.blogspot.com        second problem's solution
 int tot=2,dizi[10000];
 dizi[0] = 1;
 dizi[1] = 2;
 for(int i=2;dizi[i-1]<4000000;i++) {

  dizi[i] = dizi[i-1] +  dizi[i-2];
  if(dizi[i] % 2 == 0) {
  tot+=dizi[i];
  cout << "fibonacci row :" << dizi[i] << "----------" << "tot after plus :" << tot << "----------" << endl;
  }

 }

 cout << "Result :" <<  tot << " efekanpulatli.blogspot.com"<< endl;
}
int main()
{
 findout();
system("pause");
return 0;
}

First solution of Project Euler













#include "stdafx.h"
#include <iostream>
using namespace std;              //http://projecteuler.net/problem=1

void findout() {                  //efekanpulatli.blogspot.com        first problem's solution
int tot=0;
for(int i=1;i<1000;i++) {
if(i % 3 == 0 || i%5 == 0) {
tot+=i;
}
}
cout << tot << " efekanpulatli.blogspot.com"<< endl;
}
int main()
{
findout();
system("pause");
return 0;
}