#include <iostream>
#include <cstdio>
#include <math.h>
#define max 1000000
using namespace std;
int ary[max];
int prime [max];
int seive (){
int i,j,count=1;
for(i=3;i<=sqrt(max);i+=2){
if(ary[i]==0){
for(j=i*i;j<=max;j+=i){
ary[j]=1;
}
}
}
prime[1]=2;
for(i=3;i<=max;i+=2){
if(ary[i]==0){
count++;
prime[count]=i;
}
}
}
int prim(int num){
int i,flag=0;
if(num==2) return 1;
for(i=2;i<=sqrt(num);i++){
if(num%i==0){
flag=1;
break;
}
}
if(flag==1)
return 0;
else
return 1;
}
int main (){
seive();
int num,i,j,a,b,x,flag;
while (scanf("%d",&num)==1){
if(num==0)break;
flag=0;
for(i=1;i<=num;i++){
if(prime[i]>num||prime[i]==num) break;
a=prime[i];
b=num-prime[i];
x=prim(b);
if(x==1){
flag=1;
break;
}
}
if(flag==1)
printf("%d:\n%d+%d\n",num,a,b);
else
printf("%d:\nNO WAY!\n",num);
}
return 0;
}
#include <cstdio>
#include <math.h>
#define max 1000000
using namespace std;
int ary[max];
int prime [max];
int seive (){
int i,j,count=1;
for(i=3;i<=sqrt(max);i+=2){
if(ary[i]==0){
for(j=i*i;j<=max;j+=i){
ary[j]=1;
}
}
}
prime[1]=2;
for(i=3;i<=max;i+=2){
if(ary[i]==0){
count++;
prime[count]=i;
}
}
}
int prim(int num){
int i,flag=0;
if(num==2) return 1;
for(i=2;i<=sqrt(num);i++){
if(num%i==0){
flag=1;
break;
}
}
if(flag==1)
return 0;
else
return 1;
}
int main (){
seive();
int num,i,j,a,b,x,flag;
while (scanf("%d",&num)==1){
if(num==0)break;
flag=0;
for(i=1;i<=num;i++){
if(prime[i]>num||prime[i]==num) break;
a=prime[i];
b=num-prime[i];
x=prim(b);
if(x==1){
flag=1;
break;
}
}
if(flag==1)
printf("%d:\n%d+%d\n",num,a,b);
else
printf("%d:\nNO WAY!\n",num);
}
return 0;
}
কোন মন্তব্য নেই:
একটি মন্তব্য পোস্ট করুন