結果
問題 | No.1383 Numbers of Product |
ユーザー | 👑 emthrm |
提出日時 | 2021-02-07 22:55:53 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,693 bytes |
コンパイル時間 | 2,085 ms |
コンパイル使用メモリ | 210,300 KB |
実行使用メモリ | 92,604 KB |
最終ジャッジ日時 | 2024-07-04 17:24:45 |
合計ジャッジ時間 | 35,579 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 1 ms
5,376 KB |
testcase_03 | AC | 1 ms
5,376 KB |
testcase_04 | AC | 1 ms
5,376 KB |
testcase_05 | AC | 1 ms
5,376 KB |
testcase_06 | AC | 2 ms
5,376 KB |
testcase_07 | AC | 716 ms
55,180 KB |
testcase_08 | AC | 672 ms
54,540 KB |
testcase_09 | AC | 942 ms
82,824 KB |
testcase_10 | AC | 1,291 ms
91,956 KB |
testcase_11 | AC | 1,320 ms
90,808 KB |
testcase_12 | AC | 1,294 ms
91,708 KB |
testcase_13 | AC | 1,264 ms
89,016 KB |
testcase_14 | AC | 1,077 ms
82,704 KB |
testcase_15 | AC | 700 ms
57,480 KB |
testcase_16 | AC | 1,235 ms
91,188 KB |
testcase_17 | AC | 1 ms
5,376 KB |
testcase_18 | AC | 1 ms
5,376 KB |
testcase_19 | AC | 1 ms
5,376 KB |
testcase_20 | AC | 1 ms
5,376 KB |
testcase_21 | AC | 1 ms
5,376 KB |
testcase_22 | AC | 1 ms
5,376 KB |
testcase_23 | AC | 1 ms
5,376 KB |
testcase_24 | AC | 2 ms
5,376 KB |
testcase_25 | AC | 2 ms
5,376 KB |
testcase_26 | AC | 2 ms
5,376 KB |
testcase_27 | AC | 2 ms
5,376 KB |
testcase_28 | AC | 7 ms
5,376 KB |
testcase_29 | AC | 1,046 ms
82,700 KB |
testcase_30 | AC | 1,293 ms
92,600 KB |
testcase_31 | AC | 2 ms
5,376 KB |
testcase_32 | AC | 157 ms
23,164 KB |
testcase_33 | AC | 2 ms
5,376 KB |
testcase_34 | AC | 2 ms
5,376 KB |
testcase_35 | AC | 1,175 ms
86,712 KB |
testcase_36 | AC | 1,155 ms
84,028 KB |
testcase_37 | AC | 1,328 ms
92,472 KB |
testcase_38 | AC | 1,330 ms
92,604 KB |
testcase_39 | AC | 1,181 ms
92,596 KB |
testcase_40 | AC | 1,191 ms
92,596 KB |
testcase_41 | AC | 1,316 ms
92,600 KB |
testcase_42 | AC | 1,327 ms
92,468 KB |
testcase_43 | AC | 1,333 ms
92,604 KB |
testcase_44 | AC | 1,252 ms
92,468 KB |
testcase_45 | AC | 1,329 ms
92,468 KB |
testcase_46 | AC | 2 ms
5,376 KB |
testcase_47 | AC | 1,306 ms
91,448 KB |
testcase_48 | AC | 1,281 ms
91,960 KB |
testcase_49 | AC | 1,308 ms
92,472 KB |
testcase_50 | WA | - |
testcase_51 | AC | 2 ms
5,376 KB |
testcase_52 | AC | 2 ms
5,376 KB |
ソースコード
#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; if (n < k + 1 || m > 4) { cout << 0 << '\n'; return 0; } if (n <= 10000000) { vector<int> f(n + 1, 0); for (int a = 1; (k + a) * a <= n; ++a) { ll mul = (k + a) * a; ++f[mul]; int b = 2; while (true) { mul *= a + k * b; if (mul > n) break; ++f[mul]; ++b; } } int ans = 0; FOR(i, 1, n + 1) ans += f[i] == m; cout << ans << '\n'; return 0; } double log10_n_EPS = log10(n) + 0.1; 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 * (a + k); assert(mul <= n); ++mp[mul]; int b = 2; while (log10(mul) + log10(a + b * k) < log10_n_EPS) { mul *= a + b * k; if (mul > n) break; ++mp[mul]; ++b; } } ll lb = a - 1, ub = static_cast<ll>(ceil(sqrt(n))) + 1; while (ub - lb > 1) { ll mid = (lb + ub) >> 1; (log10(mid) + log10(mid + k) < log10_n_EPS && mid * (mid + k) <= n ? lb : ub) = mid; } ll l = a * (a + k), r = lb * (lb + k); auto check = [&](ll x) { if (lb < a || x < l || r < x) return false; if (x == l || x == r) return true; ll low = a + 1, high = min(lb, static_cast<ll>(ceil(sqrt(x))) + 1); while (high - low > 1) { ll mid = (low + high) >> 1; (mid * (mid + k) <= x ? low : high) = mid; } return low * (low + k) == x; }; ll 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; }