結果

問題 No.1383 Numbers of Product
ユーザー 👑 emthrmemthrm
提出日時 2021-02-07 21:54:06
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,879 bytes
コンパイル時間 2,275 ms
コンパイル使用メモリ 206,672 KB
実行使用メモリ 93,644 KB
最終ジャッジ日時 2023-09-17 21:24:13
合計ジャッジ時間 45,224 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
8,756 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 915 ms
53,624 KB
testcase_08 AC 918 ms
53,120 KB
testcase_09 AC 1,291 ms
82,904 KB
testcase_10 AC 1,697 ms
89,420 KB
testcase_11 AC 1,674 ms
88,232 KB
testcase_12 AC 1,698 ms
89,032 KB
testcase_13 AC 1,691 ms
86,664 KB
testcase_14 AC 1,377 ms
82,780 KB
testcase_15 AC 1,029 ms
55,784 KB
testcase_16 AC 1,752 ms
88,620 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 WA -
testcase_21 AC 1 ms
4,376 KB
testcase_22 WA -
testcase_23 AC 2 ms
4,380 KB
testcase_24 WA -
testcase_25 AC 2 ms
4,376 KB
testcase_26 WA -
testcase_27 AC 1,607 ms
4,376 KB
testcase_28 AC 11 ms
4,660 KB
testcase_29 AC 1,349 ms
82,908 KB
testcase_30 AC 1,613 ms
89,816 KB
testcase_31 AC 2 ms
4,376 KB
testcase_32 AC 282 ms
22,648 KB
testcase_33 AC 501 ms
4,376 KB
testcase_34 AC 2 ms
4,380 KB
testcase_35 AC 1,496 ms
84,444 KB
testcase_36 AC 1,490 ms
82,776 KB
testcase_37 AC 1,623 ms
89,832 KB
testcase_38 AC 1,657 ms
89,940 KB
testcase_39 AC 1,657 ms
89,952 KB
testcase_40 AC 1,650 ms
89,812 KB
testcase_41 AC 1,639 ms
89,952 KB
testcase_42 AC 1,617 ms
89,884 KB
testcase_43 AC 1,625 ms
89,936 KB
testcase_44 AC 1,609 ms
89,944 KB
testcase_45 AC 1,610 ms
89,812 KB
testcase_46 AC 2 ms
4,376 KB
testcase_47 TLE -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr double EPS = 1e-8;
constexpr int MOD = 1000000007;
// constexpr int MOD = 998244353;
constexpr int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
constexpr int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  ll n, k, m; cin >> n >> k >> m;
  unordered_map<ll, int> mp;
  ll a = 1;
  for (; log10(a) + log10(a + k) + log10(a + k * 2) < log10(n) + EPS; ++a) {
    ll mul = a;
    int b = 1;
    while (log10(mul) + log10(a + b * k) < log10(n) + EPS) {
      mul *= a + b * k;
      if (mul <= n) ++mp[mul];
      ++b;
    }
  }
  ll lb = a - 1, ub = 1000000000;
  while (ub - lb > 1) {
    ll mid = (lb + ub) >> 1;
    (mid * (mid + k) <= n ? lb : ub) = mid;
  }
  auto check = [&](ll x) {
    if (lb < a) return false;
    ll s = ceil(sqrt(x)) + 1;
    while (s * (s + k) > x) --s;
    return s * (s + k) == x && a <= s && s <= lb;
  };
  int ans = 0;
  if (m == 1) {
    for (auto [x, f] : mp) {
      if (f == 1) ans += check(x) ? -1 : 1;
    }
    ans += max(lb - a + 1, 0LL);
  } else {
    for (auto [x, f] : mp) {
      if (f == m) {
        ans += !check(x);
      } else if (f + 1 == m) {
        ans += check(x);
      }
    }
  }
  cout << ans << '\n';
  return 0;
}
0