結果

問題 No.2016 Countdown Divisors
ユーザー umimelumimel
提出日時 2022-07-22 21:48:08
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,060 bytes
コンパイル時間 2,517 ms
コンパイル使用メモリ 180,120 KB
実行使用メモリ 12,248 KB
最終ジャッジ日時 2023-09-17 09:35:30
合計ジャッジ時間 5,526 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 TLE -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
#define drep(i, cc, n) for (ll i = (cc); i <= (n); ++i)
#define rep(i, n) drep(i, 0, n - 1)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define fi first
#define se second

const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const ll INF = 1LL << 60;
const ll N_MAX = 2e5;

map<ll, ll> mp;
void dfs(ll x){
    if(mp.find(x) != mp.end()) return;
    ll cnt = 1;
    ll y = x;
    for(ll i=2; i*i<=x; i++){
        if(y%i != 0) continue;
        ll c = 0;
        while(y%i == 0){
            y/=i;
            c++;
        }

        cnt *= (c+1);
    }

    if(y != 1) cnt*=2;

    dfs(x - cnt);
    mp[x] = mp[x-cnt];
    return;
}

int main(){
    ll t;
    cin >> t;

    vector<pll> a(t);
    rep(i, t){
        cin >> a[i].fi;
        a[i].se = i;
    }
    sort(all(a));

    mp[1] = 1;
    mp[2] = 2;
    vector<ll> ans(t);
    rep(i, t){
        dfs(a[i].fi);
        ans[a[i].se] = mp[a[i].fi];
    }

    rep(i, t) cout << ans[i] << endl;
}
0