結果

問題 No.2016 Countdown Divisors
ユーザー yansi819yansi819
提出日時 2024-04-14 16:04:06
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 591 bytes
コンパイル時間 4,830 ms
コンパイル使用メモリ 260,448 KB
実行使用メモリ 10,780 KB
最終ジャッジ日時 2024-04-14 16:04:17
合計ジャッジ時間 8,656 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
10,780 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>
#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