About Me

About Me : I have been working as a Software Engineer for various international companies for four years.Currently, I am working as a full stack Javascript developer in Petronas(Malaysia).

Skills

Skills • Javascript •Typescript •Python •C •Java •ReactJs • Redux • VueJs • NestJs • React Testing Library • Django• PostgreSQL • MySQL • NodeJs • Git • Docker • Jira • Visual Studio Code • Slack

মঙ্গলবার, ১১ মার্চ, ২০১৪

UVA :10394 - Twin Primes


link#


#include <iostream>
#include <cstdio>
#include <math.h>
#define max 20000000
using namespace std;
int a[max];
int p[20000010];
int l[20000000];
void seive (){

   int i,sq,j,c=1,m=0;
    sq=sqrt(max);
 for(i=3;i<=sq;i+=2){
    if(a[i]==0){
       for(j=i*i;j<max;j+=i) {
           a[j]=1;
       }
    }
 }
   p[c]=2;

   for(i=3;i<max;i+=2){
     if(a[i]==0){
            c++;
        p[c]=i;
     }
   }
     for(i=1;i<=c;i++){
        if(p[i+1]-p[i]==2){
                m++;
           l[m]=p[i];
        }

     }



}
int main (){
seive();
int num;
while(scanf("%d",&num)!=EOF){
  printf("(%d, %d)\n",l[num],l[num]+2);


}

return 0;
}