結果
問題 | No.2425 Power Range GCD |
ユーザー |
|
提出日時 | 2023-08-18 21:16:15 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 256 ms / 2,000 ms |
コード長 | 793 bytes |
コンパイル時間 | 1,900 ms |
コンパイル使用メモリ | 199,592 KB |
最終ジャッジ日時 | 2025-02-16 09:25:03 |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 31 |
ソースコード
#include <bits/stdc++.h>#define rep(i, n) for (int i = 0; i < n; ++i)typedef long long ll;using namespace std;map<ll, ll> prime_factor(ll n) {ll m = n;map<ll, ll> ret;for (ll i = 2; i * i <= n; i++) {while (n % i == 0) {ret[i] += m;n /= i;}}if (n != 1)ret[n] = m;return ret;}int main() {cin.tie(0)->sync_with_stdio(0);int L, R;cin >> L >> R;map<ll, ll> pf = prime_factor(L);for (int i = L + 1; i <= R; ++i) {map<ll, ll> cur = prime_factor(i);for (auto &[k, v] : pf) {pf[k] = min(v, cur[k]);}}ll ans = 1;for (auto &[k, v] : pf) {while (v--)ans *= k;}cout << ans << "\n";return 0;}