結果

問題 No.1611 Minimum Multiple with Double Divisors
ユーザー yuji9511yuji9511
提出日時 2021-07-21 22:02:54
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,266 bytes
コンパイル時間 3,639 ms
コンパイル使用メモリ 208,228 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-24 17:36:54
合計ジャッジ時間 7,873 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 493 ms
4,380 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 36 ms
4,380 KB
testcase_14 AC 37 ms
4,376 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 37 ms
4,380 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 3 ms
4,376 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 3 ms
4,376 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 2 ms
4,376 KB
testcase_31 AC 1 ms
4,376 KB
testcase_32 AC 2 ms
4,376 KB
testcase_33 AC 1 ms
4,380 KB
testcase_34 AC 2 ms
4,376 KB
testcase_35 AC 2 ms
4,380 KB
testcase_36 AC 2 ms
4,380 KB
testcase_37 AC 2 ms
4,380 KB
testcase_38 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/*** author: yuji9511 ***/
#include <bits/stdc++.h>
// #include <atcoder/all>
// using namespace atcoder;
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
using vll = vector<ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
ostream& operator<<(ostream& os, lpair& h){ os << "(" << h.first << ", " << h.second << ")"; return os;}
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
vll factor(ll M){
    vll fac;
    if(M == 1){
        fac.push_back(1); return fac;
    }
    for(ll i = 2; i*i <= M; i++){
        while(M % i == 0){
            fac.push_back(i); M /= i;
        }
    }
    if(M != 1) fac.push_back(M);
    sort(fac.begin(), fac.end());
    return fac;
}


void solve3(){
    ll N;
    cin >> N;
    rep(i,2,100){
        vll d = factor(i);
        if(d.size() == 1){
            if(N % i != 0){
                print(N*i);
                return;
            }
        }else if(d.size() == 2 && d[0] != d[1]){
            vll cnt(2, 0);
            rep(j,0,2){
                ll v = N;
                while(v % d[j] == 0){
                    cnt[j]++;
                    v /= d[j];
                }
            }
            if(cnt[0] * cnt[1] == 2){
                print(N*i);
                return;
            }
        }else{
            ll sz = d.size();
            vll v2 = d;
            v2.erase(unique(v2.begin(), v2.end()), v2.end());
            if(v2.size() == 1){
                ll cnt = 0;
                ll v = N;
                while(v % v2[0] == 0){
                    cnt++;
                    v /= v2[0];
                }
                if(cnt == sz-1){
                    print(N*i);
                    return;
                }

            }
        }
    }

}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll t;
    cin >> t;
    while(t--) solve3();
}
0