//快速幂 //ll qpow(ll b, ll n) { // ll ret = 1; // b %= mod; // for (; n; n >>= 1, b = (b * b) % mod) // if (n & 1) ret = (ret * b) % mod; // return ret; //} ll res = 1; constint mod = 1000000007; bool st[N]; unordered_map<int, bool> mp; unordered_map<int, int> mp2; ll gcd(ll a, ll b) { ll temp = 0; while (temp = a % b) { a = b; b = temp; } return b; }
voiddivide(int n){ unordered_map<int, int> mp1; mp1.clear(); for (int i = 2; i <= n / i; i++) { if (n % i == 0) { int s = 0; while (n % i == 0) { n /= i; s++; } //cout << i << " " << s << endl; mp1[i] += s; } } //if (n > 1)cout << n << " " << 1 << endl; //puts(""); if(n > 1)mp1[n] += 1; for (auto m : mp1) { int x = m.first, y = m.second; //cout << x << " " << y << endl; if (mp2[x] < y)for (int i = 0; i < y - mp2[x]; i++)res = (res % mod * x) % mod; mp2[x] = max(y, mp2[x]); } //cout << endl; }
voidget_prime(int n){ for (int i = 2; i <= n; i++) { if (!st[i])mp[i] = true;//把素数存起来 for (int j = i; j <= n; j += i) {//不管是合数还是质数,都用来筛掉后面它的倍数 st[j] = true; } } }
voidf(){ int l, r; cin >> l >> r; get_prime(r); vector<int> v; for (int i = l; i <= r; i++) { if (mp[i] == false) { v.push_back(i); } } int n = v.size(); if (n == 0) { cout << -1 << endl; return; } //res = v[0]; //a * b / gcd(a, b) << endl; //res = ((res * v[i]) % mod / gcd(res, v[i])) % mod; for (int i = 0; i < n; i++) { divide(v[i]); } cout << res % mod<< endl; } intmain() { f(); return0; }