#include<bits/stdc++.h> using namespace std; #define ll long long #define pb push_back int main() { ll i,j; ll prime[31624]; for(i=0;i<31624;i++) prime[i]=1; prime[0]=0; prime[1]=0; for(i=2;i<31624;i++) { if(prime[i]==1) { for(j=2;(i*j)<31624;j++) { prime[i*j]=0; } } } vector<ll> p; for(i=0;i<31624;i++) { if(prime[i]==1) { p.pb(i); } } for(i=0;i<p.size();i++) cout<<p[i]<<" "; ll t,n,k,m,x,y,p2; cin>>n>>p2; ll ans=1; ll c=0; if(n==1) { cout<<p2; } else { if(p2<31623) { for(i=0;i<p.size();i++) { if(p[i]==p2) { if((i+n-2)<p.size()) { ans=p2*p[i+n-2]; if(ans>1000000000) cout<<"0"; else cout<<ans; } break; } } } else cout<<"0"; } return 0; }
Asked by: Manish_Kumar_Savita on April 7, 2019, 6:34 p.m. Last updated on April 7, 2019, 6:34 p.m.