题解 | #珂朵莉的数论题#
珂朵莉的数论题
https://ac.nowcoder.com/acm/problem/14832
#include<iostream> #define MAX 1000000000 using namespace std; int main() { int x,y; cin>>x>>y; if(y==2||x==1) { long long res=x*y; if(res>MAX) cout<<0; else cout<<res; return 0; } int sum=0; for(int i=y;x>1;i+=2) { sum=y*i; if(sum>MAX) break; int j; for(j=3;j<y;j+=2) { if(i%j==0) break; } if(j>=y) x--; } if(x!=1) sum=0; cout<<sum; return 0; }