結果

問題 No.1611 Minimum Multiple with Double Divisors
ユーザー milanis48663220milanis48663220
提出日時 2021-07-21 21:52:18
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,266 ms / 2,000 ms
コード長 1,932 bytes
コンパイル時間 3,309 ms
コンパイル使用メモリ 128,040 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-07-26 15:21:36
合計ジャッジ時間 24,807 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,266 ms
4,384 KB
testcase_01 AC 1,020 ms
4,380 KB
testcase_02 AC 1,008 ms
4,384 KB
testcase_03 AC 1,009 ms
4,384 KB
testcase_04 AC 1,005 ms
4,380 KB
testcase_05 AC 1,012 ms
4,380 KB
testcase_06 AC 1,007 ms
4,380 KB
testcase_07 AC 1,015 ms
4,380 KB
testcase_08 AC 1,008 ms
4,384 KB
testcase_09 AC 1,012 ms
4,380 KB
testcase_10 AC 830 ms
4,380 KB
testcase_11 AC 841 ms
4,384 KB
testcase_12 AC 837 ms
4,380 KB
testcase_13 AC 830 ms
4,384 KB
testcase_14 AC 832 ms
4,384 KB
testcase_15 AC 824 ms
4,380 KB
testcase_16 AC 824 ms
4,380 KB
testcase_17 AC 832 ms
4,384 KB
testcase_18 AC 828 ms
4,380 KB
testcase_19 AC 10 ms
4,380 KB
testcase_20 AC 10 ms
4,380 KB
testcase_21 AC 10 ms
4,388 KB
testcase_22 AC 10 ms
4,384 KB
testcase_23 AC 10 ms
4,384 KB
testcase_24 AC 10 ms
4,380 KB
testcase_25 AC 10 ms
4,384 KB
testcase_26 AC 10 ms
4,380 KB
testcase_27 AC 11 ms
4,384 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 2 ms
4,384 KB
testcase_30 AC 2 ms
4,384 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 AC 2 ms
4,384 KB
testcase_33 AC 2 ms
4,384 KB
testcase_34 AC 2 ms
4,384 KB
testcase_35 AC 2 ms
4,380 KB
testcase_36 AC 2 ms
4,380 KB
testcase_37 AC 2 ms
4,384 KB
testcase_38 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cmath>
#include <numeric>
#include <functional>
#include <cassert>

#define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl;
#define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using namespace std;
typedef long long ll;

vector<int> primes = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31};
vector<vector<int>> vs;

void dfs(int prod, int i, vector<int> &v){
    if(!v.empty()){
        vs.push_back(v);
    }
    for(int j = i; j < primes.size(); j++){
        if(prod*primes[j] <= 31) {
            v.push_back(primes[j]);
            dfs(prod*primes[j], j, v);
            v.pop_back();
        }
    }
}

void init(){
    vector<int> v;
    dfs(1, 0, v);
}

bool ok(ll x, vector<int> v){
    ll y = x;
    set<int> st;
    for(int p: v) {
        y *= p;
        st.insert(p);
    }
    ll a = 1;
    ll b = 1;
    for(int p: st){
        int cnt_x = 0, cnt_y = 0;
        while(x%p == 0){
            x /= p;
            cnt_x++;
        }
        while(y%p == 0){
            y /= p;
            cnt_y++;
        }
        a *= cnt_x+1;
        b *= cnt_y+1;
    }
    return a*2 == b;
}

void solve(){
    ll x; cin >> x;
    int ans = 100;
    for(auto v: vs){
        if(ok(x, v)){
            int prod = accumulate(v.begin(), v.end(), 1, [](int a, int b){ return a*b; });
            chmin(ans, prod);
        }
    }
    cout << ans*x << endl;

}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    init();
    int t; cin >> t;
    while(t--) solve();
}
0