結果
問題 |
No.1611 Minimum Multiple with Double Divisors
|
ユーザー |
|
提出日時 | 2022-03-16 16:40:19 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 1,512 ms / 2,000 ms |
コード長 | 991 bytes |
コンパイル時間 | 2,384 ms |
コンパイル使用メモリ | 195,484 KB |
最終ジャッジ日時 | 2025-01-28 09:52:52 |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 37 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define bokusunny ios::sync_with_stdio(false), cin.tie(nullptr); bool is_prime(long long x) { if (x == 1) return false; long long i = 2; while (i * i <= x) { if (x % i == 0) return false; i++; } return true; } void solve() { long long x; cin >> x; vector<int> P; for (int p = 2; p <= 31; p++) { if (is_prime(p)) P.push_back(p); } long long xx = x; long long cntx = 1; for (auto &p : P) { int ex = 1; while (xx % p == 0) { xx /= p; ex++; } cntx *= ex; } for (long long y = x * 2; y <= x * 31; y += x) { long long yy = y; long long cnty = 1; for (auto &p : P) { int ey = 1; while (yy % p == 0) { yy /= p; ey++; } cnty *= ey; } if ((cnty >> 1) == cntx) { cout << y << endl; return; } } assert(false); } int main() { bokusunny; int t; cin >> t; while (t--) solve(); return 0; }