রবিবার, ২৮ আগস্ট, ২০১৬

UVA 543 - Goldbach's Conjecture

///...................SUBHASHIS MOLLICK....................///
///.....DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING....///
///.............ISLAMIC UNIVERSITY,BANGLADESH.............///
///.....................SESSION-(14-15)....................///
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<ctype.h>
#include<bits/stdc++.h>
using namespace std;
long int visit[1000000]={0},a11[1000000]={0};
main()
{

{
long int i,j,p;
        long int a,a1;
   long int n;
            p=sqrt(1000000);
            visit[1]=1;
           for(i=3;i<=p;i=i+2)
            {
   if(visit[i]==0)
                 {
       for(j=i+i;j<=1000000;j=j+i)
                    visit[j]=1;
    }
            }
            long int j1,j2,k=0;
            for(j1=3;j1<1000000;j1=j1+2)
              {

           if(visit[j1]==0)
           {
    a11[k]=j1;
 k++;
   }
         }
 //printf("%ld",k);
}
long int i1,i2,c1,c2,n;
while(scanf("%ld",&n)!=EOF)
{
if(n==0)
break;
for(i1=0;i1<=n/2;i1++)
{
c1=n-a11[i1];
if(visit[c1]==0)
{
printf("%ld = %ld + %ld\n",n,a11[i1],c1);
break;
}
}
}


}

কোন মন্তব্য নেই:

একটি মন্তব্য পোস্ট করুন

Factory Pattern

Factory Method  is a creational design pattern that provides an interface for creating objects in a superclass but allows subclasses to alte...