結果
問題 | No.1383 Numbers of Product |
ユーザー | milanis48663220 |
提出日時 | 2021-07-01 22:48:50 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,345 bytes |
コンパイル時間 | 1,494 ms |
コンパイル使用メモリ | 125,996 KB |
実行使用メモリ | 68,496 KB |
最終ジャッジ日時 | 2023-09-10 20:40:25 |
合計ジャッジ時間 | 25,419 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,380 KB |
testcase_01 | AC | 2 ms
4,380 KB |
testcase_02 | AC | 2 ms
4,380 KB |
testcase_03 | AC | 2 ms
4,384 KB |
testcase_04 | AC | 2 ms
4,380 KB |
testcase_05 | AC | 1 ms
4,380 KB |
testcase_06 | AC | 1 ms
4,380 KB |
testcase_07 | AC | 477 ms
43,084 KB |
testcase_08 | AC | 568 ms
42,708 KB |
testcase_09 | AC | 587 ms
51,944 KB |
testcase_10 | AC | 791 ms
67,816 KB |
testcase_11 | AC | 776 ms
66,636 KB |
testcase_12 | AC | 789 ms
67,488 KB |
testcase_13 | AC | 908 ms
64,908 KB |
testcase_14 | AC | 631 ms
55,316 KB |
testcase_15 | AC | 500 ms
45,392 KB |
testcase_16 | AC | 777 ms
66,820 KB |
testcase_17 | AC | 2 ms
4,384 KB |
testcase_18 | AC | 1 ms
4,376 KB |
testcase_19 | AC | 2 ms
4,376 KB |
testcase_20 | WA | - |
testcase_21 | AC | 1 ms
4,380 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 | 2 ms
4,380 KB |
testcase_28 | AC | 9 ms
4,376 KB |
testcase_29 | AC | 600 ms
53,368 KB |
testcase_30 | AC | 803 ms
68,176 KB |
testcase_31 | AC | 2 ms
4,380 KB |
testcase_32 | AC | 141 ms
16,708 KB |
testcase_33 | AC | 1 ms
4,380 KB |
testcase_34 | AC | 2 ms
4,380 KB |
testcase_35 | AC | 721 ms
62,588 KB |
testcase_36 | AC | 825 ms
59,896 KB |
testcase_37 | AC | 956 ms
68,192 KB |
testcase_38 | AC | 799 ms
68,208 KB |
testcase_39 | AC | 799 ms
68,188 KB |
testcase_40 | AC | 795 ms
68,208 KB |
testcase_41 | AC | 957 ms
68,276 KB |
testcase_42 | AC | 802 ms
68,496 KB |
testcase_43 | AC | 962 ms
68,252 KB |
testcase_44 | AC | 794 ms
68,256 KB |
testcase_45 | AC | 798 ms
68,212 KB |
testcase_46 | AC | 1 ms
4,380 KB |
testcase_47 | AC | 773 ms
66,700 KB |
testcase_48 | AC | 786 ms
67,316 KB |
testcase_49 | AC | 796 ms
67,964 KB |
testcase_50 | AC | 945 ms
67,844 KB |
testcase_51 | WA | - |
testcase_52 | WA | - |
ソースコード
#include <iostream> #include <algorithm> #include <iomanip> #include <vector> #include <queue> #include <set> #include <map> #include <tuple> #include <cmath> #include <numeric> #include <functional> #include <cassert> #define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl; #define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl; template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } using namespace std; typedef long long ll; const ll INF = 2e18; ll calc(ll a, ll b, ll k){ ll ans = a; for(ll i = 1; i <= b; i++){ ll x = a+k*i; if(ans >= INF/x) return INF; ans *= x; } // cout << "calc(" << a << "," << b << "," << k << ") = " << ans << endl; return ans; } ll f(ll x, ll k){ ll l = 0, r = 1e9; while(r-l > 1){ ll c = (l+r)/2; if(c*(c+k) > x) r = c; else l = c; } return l; } int naive(ll n, ll k, ll m){ map<ll, int> cnt; for(int b = 1; ; b++){ if(calc(1, b, k) > n) break; for(int a = 1; ; a++){ ll x = calc(a, b, k); if(x > n) break; if(cnt.count(x) == 0) cnt[x] = 1; else cnt[x]++; } } int ans = 0; for(auto [_, c]: cnt){ if(c == m) ans++; } return ans; } int main(){ ios::sync_with_stdio(false); cin.tie(0); cout << setprecision(10) << fixed; ll n, k, m; cin >> n >> k >> m; map<ll, int> cnt; for(int b = 2; ; b++){ if(calc(1, b, k) > n) break; for(int a = 1; ; a++){ ll x = calc(a, b, k); if(x > n) break; if(cnt.count(x) == 0) cnt[x] = 1; else cnt[x]++; } } vector<ll> v; for(auto &[x, c]: cnt) { ll y = f(x, k); if(y*(y+k) == x){ v.push_back(x); c++; } } int ans = 0; for(auto [_, c]: cnt){ if(c == m) ans++; } if(m == 1){ ll y = f(n, k); ans += y; for(auto [x, c]: cnt){ ll y = f(x, k); if(y*(y+k) == x) ans--; } } cout << ans << endl; // cout << naive(n, k, m) << endl; }