Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- using namespace std;
- const long long N =100000002;
- int esPrimo[N];
- void criba(long long n){
- for (long long i=0;i<=n;i++) esPrimo[i]=1;
- esPrimo[0]=esPrimo[1]=0;
- for (long long p=2;p<=n;p++){
- if (esPrimo[p])
- for(long long mul=p*p;mul<N;mul+=p) esPrimo[mul]=0;
- }
- }
- int main(){
- criba(100000001);
- int num;
- while((cin>>num) && (num!=0)){
- int encontrado=0,a=2;
- while(!esPrimo[num-a]){
- a++;
- while(!esPrimo[a]) a++;
- }
- cout<<num<<" = "<<a<<" + "<<(num-a)<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment