結果

問題 No.1611 Minimum Multiple with Double Divisors
ユーザー t9unkubj
提出日時 2025-02-11 17:00:08
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 1,125 ms / 2,000 ms
コード長 1,646 bytes
コンパイル時間 3,503 ms
コンパイル使用メモリ 295,672 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2025-02-11 17:00:22
合計ジャッジ時間 11,342 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 37
権限があれば一括ダウンロードができます

ソースコード

diff #

#ifdef t9unkubj
#include"debug.cpp"
//#include"template_no_debug.h"
#else 
#define dbg(...) 199958
#endif

#undef _GLIBCXX_DEBUG
#pragma GCC optimize("O3")
using namespace std;
#include<bits/stdc++.h>
using ll=long long;
using ull=unsigned long long;
template<class T>using vc=vector<T>;
template<class T>using vvc=vc<vc<T>>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define REP(i,j,n) for(ll i=(j);i<(ll)(n);i++)
#define DREP(i,n,m) for(ll i=(n);i>=(m);i--)
#define drep(i,n) for(ll i=((n)-1);i>=0;i--)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
template<class T,class F>
bool chmin(T &x, F y){
    if(x>y){
        x=y;
        return true;
    }
    return false;
}
template<class T, class F>
bool chmax(T &x, F y){
    if(x<y){
        x=y;
        return true;
    }
    return false;
}
double pass_time=0;

constexpr int MAX=41;
vc<ll>pr;
void solve(){
    auto f=[&](ll x,ll p){
        int cnt=0;
        while(x%p==0)x/=p,cnt++;
        return cnt;
    };
    ll x;
    cin>>x;
    
    ll prod=1;
    for(auto&p:pr){
        prod*=(f(x,p)+1);
    }
    for(ll i=2;;i++){
        ll prod2=1;
        dbg(x*i);
        for(auto&p:pr)dbg(f(x*i,p)+1),prod2*=(f(x*i,p)+1);
        dbg(prod,prod2);
        if(prod*2==prod2){
            cout<<x*i<<"\n";
            return;
        }
    }
}
signed main(){
    for(int i=2;i<MAX;i++){
        int ok=1;
        for(int j=2;j*j<=i;j++)if(i%j==0)ok=0;
        if(ok)pr.push_back(i);
    }
    cin.tie(0)->sync_with_stdio(0);
    pass_time=clock();
    int t=1;
    cin>>t;
    while(t--)solve();
    pass_time=clock()-pass_time;
    dbg(pass_time/CLOCKS_PER_SEC);
}
0