結果

問題 No.1611 Minimum Multiple with Double Divisors
ユーザー momoyuu
提出日時 2024-08-09 17:25:52
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 690 ms / 2,000 ms
コード長 1,387 bytes
コンパイル時間 1,204 ms
コンパイル使用メモリ 97,496 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-08-09 17:26:00
合計ジャッジ時間 8,447 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 37
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
using ll = long long;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int t;
    cin>>t;
    const int mx = 3e5;
    vector<int> cnt(mx+1,0);
    vector<int> use;
    for(int i = 2;i<=mx;i++){
        if(cnt[i]) continue;
        use.push_back(i);
        for(int j = i;j<=mx;j+=i) cnt[j] = 1;
    }
    while(t--){
        ll a;
        cin>>a;
        ll ans = a * 100;
        ll x = a;
        for(int i = 2;i<=100;i++){
            vector<int> facs;
            int now = i;
            for(int j = 2;j*j<=i;j++) if(now%j==0){
                while(now%j==0) now /= j;
                facs.push_back(j);
            }
            if(now!=1) facs.push_back(now);
            ll p = 1;
            ll q = 1;
            for(auto&e:facs) {
                int cnt = 0;
                ll now = x;
                while(now%e==0){
                    now /= e;
                    cnt++;
                }
                int c = 0;
                now = i;
                while(now%e==0){
                    now /= e;
                    c++;
                }
                p *= (cnt+c+1);
                q *=  cnt + 1;
            }
            if(p%q==0&&p/q==2){
                ans = x * i;
                break;
            }
        }
        cout<<ans<<endl;
    }
}

0