結果

問題 No.2016 Countdown Divisors
ユーザー yansi819
提出日時 2024-04-14 16:04:06
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 591 bytes
コンパイル時間 3,973 ms
コンパイル使用メモリ 257,080 KB
最終ジャッジ日時 2025-02-21 01:47:38
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 1
other AC * 1 TLE * 1 -- * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ld = long double;
using mint = modint998244353;

map<ll, ll> mp;

ll divisors(ll n) {
  if (mp.count(n)) return mp[n];
  ll res = 0;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      res++;
      if (i * i != n) res++;
    }
  }
  return mp[n] = res;
}

int main() {
  ll t; cin >> t;
  while (t--) {
    ll n; cin >> n;
    while (true) {
      ll s = divisors(n);
      if (n - s == 0) break;
      n -= s;
    }
    cout << n << endl;
  }
  return 0;
}
0