結果

問題 No.1611 Minimum Multiple with Double Divisors
ユーザー んんんんんん
提出日時 2022-12-30 13:24:02
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 611 bytes
コンパイル時間 1,973 ms
コンパイル使用メモリ 193,580 KB
最終ジャッジ日時 2025-02-09 22:05:20
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 9 WA * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int ps[11] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31};

int main() {
    int T;
    cin >> T;
    while (T--) {
        long long X;
        cin >> X;
        if (X % 2) {
            cout << 2*X << endl;
            continue;
        }

        int mini = 1 << 30;
        for (int i = 0; i < 11; i++) {
            long long x = X;
            int p = ps[i];
            int n = 1;
            while (x % p == 0) {
                x /= p;
                n *= p;
            }
            mini = min(mini, n*p);
        }

        cout << mini*X << endl;
    }
}
0