結果

問題 No.1611 Minimum Multiple with Double Divisors
ユーザー zhanghonghe2zhanghonghe2
提出日時 2021-07-22 00:44:54
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 947 ms / 2,000 ms
コード長 1,502 bytes
コンパイル時間 849 ms
コンパイル使用メモリ 79,632 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-14 05:33:17
合計ジャッジ時間 12,261 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 947 ms
6,812 KB
testcase_01 AC 612 ms
6,944 KB
testcase_02 AC 593 ms
6,944 KB
testcase_03 AC 592 ms
6,940 KB
testcase_04 AC 591 ms
6,944 KB
testcase_05 AC 604 ms
6,940 KB
testcase_06 AC 608 ms
6,940 KB
testcase_07 AC 602 ms
6,944 KB
testcase_08 AC 601 ms
6,944 KB
testcase_09 AC 603 ms
6,944 KB
testcase_10 AC 164 ms
6,944 KB
testcase_11 AC 175 ms
6,940 KB
testcase_12 AC 174 ms
6,940 KB
testcase_13 AC 172 ms
6,944 KB
testcase_14 AC 173 ms
6,940 KB
testcase_15 AC 174 ms
6,944 KB
testcase_16 AC 171 ms
6,940 KB
testcase_17 AC 173 ms
6,940 KB
testcase_18 AC 174 ms
6,944 KB
testcase_19 AC 4 ms
6,940 KB
testcase_20 AC 4 ms
6,940 KB
testcase_21 AC 4 ms
6,940 KB
testcase_22 AC 4 ms
6,940 KB
testcase_23 AC 4 ms
6,944 KB
testcase_24 AC 4 ms
6,940 KB
testcase_25 AC 3 ms
6,944 KB
testcase_26 AC 4 ms
6,940 KB
testcase_27 AC 3 ms
6,944 KB
testcase_28 AC 2 ms
6,940 KB
testcase_29 AC 2 ms
6,940 KB
testcase_30 AC 2 ms
6,940 KB
testcase_31 AC 2 ms
6,944 KB
testcase_32 AC 2 ms
6,944 KB
testcase_33 AC 2 ms
6,944 KB
testcase_34 AC 2 ms
6,940 KB
testcase_35 AC 2 ms
6,940 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
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <set>
#define ll long long
using namespace std;

const int maxn=1000;
ll vis[maxn];
vector<ll> prime;

void init(){
    for(int i=2;i<maxn;i++){
        if(vis[i]==0) {
            prime.push_back(i);
            for(int j=i;j<maxn;j+=i){
                vis[j]=i;
            }
        }
    }
}

set<ll> s;

bool check(ll i,ll x){
    //if(x%i==0) return false;
    ll i2=i;
    s.clear();
    while(i2!=1){
        s.insert(vis[i2]);
        i2/=vis[i2];
    }
    vector<int> cnt1(s.size());
    vector<int> cnt2(s.size());

    int now=0;
    for(ll j:s){
        while(i%j==0) {
            i/=j;
            cnt1[now]+=1;
        }
        while(x%j==0){
            x/=j;
            cnt2[now]+=1;
        }
        now+=1;
    }

    int sum1=1;int sum2=1;
    for(int j:cnt2) sum1*=(j+1);
    for(int j=0;j<cnt2.size();j++){
        cnt2[j]+=cnt1[j];
        sum2*=(cnt2[j]+1);
    }

    return sum2==2*sum1;
}

int main(){
    ios::sync_with_stdio(false);
    int T;cin>>T;
    init();

    while(T--){
        ll X;cin>>X;

        ll p=-1;
        for(ll i:prime){
            if(X%i!=0){
                p=i;
                break;
            }
        }
        ll ans=p*X;

        for(ll i=p-1;i>=2;i--){
            //i 是一个合数,i可以被X的因子表示,但是i不能被X整除。
            if(check(i,X)){
                ans=i*X;
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}
0