結果

問題 No.1611 Minimum Multiple with Double Divisors
ユーザー nawawannawawan
提出日時 2021-07-21 22:42:22
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 842 ms / 2,000 ms
コード長 1,506 bytes
コンパイル時間 1,806 ms
コンパイル使用メモリ 173,144 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-14 05:23:11
合計ジャッジ時間 10,449 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 842 ms
6,816 KB
testcase_01 AC 313 ms
6,812 KB
testcase_02 AC 306 ms
6,940 KB
testcase_03 AC 310 ms
6,944 KB
testcase_04 AC 308 ms
6,940 KB
testcase_05 AC 302 ms
6,944 KB
testcase_06 AC 307 ms
6,944 KB
testcase_07 AC 305 ms
6,940 KB
testcase_08 AC 304 ms
6,944 KB
testcase_09 AC 313 ms
6,940 KB
testcase_10 AC 181 ms
6,940 KB
testcase_11 AC 207 ms
6,948 KB
testcase_12 AC 206 ms
6,940 KB
testcase_13 AC 208 ms
6,944 KB
testcase_14 AC 203 ms
6,940 KB
testcase_15 AC 210 ms
6,944 KB
testcase_16 AC 202 ms
6,940 KB
testcase_17 AC 203 ms
6,944 KB
testcase_18 AC 209 ms
6,940 KB
testcase_19 AC 4 ms
6,940 KB
testcase_20 AC 4 ms
6,944 KB
testcase_21 AC 4 ms
6,944 KB
testcase_22 AC 4 ms
6,940 KB
testcase_23 AC 4 ms
6,944 KB
testcase_24 AC 4 ms
6,944 KB
testcase_25 AC 4 ms
6,940 KB
testcase_26 AC 4 ms
6,940 KB
testcase_27 AC 4 ms
6,944 KB
testcase_28 AC 1 ms
6,940 KB
testcase_29 AC 2 ms
6,944 KB
testcase_30 AC 2 ms
6,944 KB
testcase_31 AC 2 ms
6,940 KB
testcase_32 AC 2 ms
6,944 KB
testcase_33 AC 2 ms
6,940 KB
testcase_34 AC 2 ms
6,944 KB
testcase_35 AC 2 ms
6,944 KB
testcase_36 AC 2 ms
6,940 KB
testcase_37 AC 2 ms
6,944 KB
testcase_38 AC 2 ms
6,944 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:34:26: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
   34 |                 for(auto [v, ko] : m){
      |                          ^
main.cpp:42:26: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
   42 |                 for(auto [v, ko] : m){
      |                          ^

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
    int testcase;
    cin >> testcase;
    vector<int> prime(100, -1);
    for(int i = 2; i < 100; i++){
        if(prime[i] != -1) continue;
        int t = i;
        prime[i] = i;
        while(t + i < 100){
            t += i;
            prime[t] = i;
        }
    }
    while(testcase--){
        long long X;
        cin >> X;
        if(X % 2 == 1) cout << X * 2 << endl;
        else{
            long long res0 = 1000000000000000;
            for(long long i = 2; i < 100; i++){
                if(prime[i] == i && X % i != 0){
                    res0 = min(res0, i);
                    break;
                }
                map<int, int> m, m2;
                int t = i;
                while(t != 1){
                    m[prime[t]]++;
                    t /= prime[t];
                }
                long long temp = X;
                for(auto [v, ko] : m){
                    while(temp % v == 0){
                        m2[v]++;
                        temp /= v;
                    }
                }
                long long res = 1;
                temp = 1;
                for(auto [v, ko] : m){
                    res *= (m2[v] + 1);
                    temp *= (m2[v] + ko + 1);
                }
                if(temp % res == 0 && temp / res == 2){
                    res0 = min(res0, i);
                    break;
                }
            }
            cout << X * res0 << endl;
        }
    }
}
0