Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- typedef long long ll;
- #include <ext/pb_ds/assoc_container.hpp>
- using namespace __gnu_pbds;
- typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
- #define suni ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
- #define endl "\n"
- #define mn int main()
- #define frac() cout.unsetf(ios::floatfield);cout.precision(6);cout.setf(ios::fixed,ios::floatfield);
- const int mx=1e6+123;
- bool isprime[mx];
- vector<int>prime;
- void primegen(int n){
- memset(isprime,1,sizeof(isprime));
- isprime[1]=0;
- for(int i=2;i<=n;i++){
- for(int j=i+i;j<=n;j+=i)
- isprime[j]=0;
- }
- for(int i=3;i<=n;i++){
- if(isprime[i]) prime.push_back(i);
- }
- }
- mn
- {
- suni;
- primegen(1e6);
- int n;
- while(cin>>n){
- if(n==0) break;
- int p1=-1,p2=-1;
- for(auto u: prime){
- if(u>n) break;
- int tp1=u,tp2=n-u;
- if(tp2>2 && isprime[tp2]==1){
- p1=tp1;
- p2=tp2;
- break;
- }
- }
- cout<<n<<" = "<<p1<<" + "<<p2<<endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement