結果

問題 No.1532 Different Products
ユーザー そすうぽよそすうぽよ
提出日時 2021-06-05 13:03:42
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 890 bytes
コンパイル時間 2,550 ms
コンパイル使用メモリ 211,284 KB
実行使用メモリ 194,832 KB
最終ジャッジ日時 2023-12-13 16:28:51
合計ジャッジ時間 87,160 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 448 ms
38,572 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 3 ms
6,676 KB
testcase_08 AC 5 ms
6,676 KB
testcase_09 AC 74 ms
12,544 KB
testcase_10 AC 632 ms
45,320 KB
testcase_11 AC 426 ms
34,384 KB
testcase_12 AC 1,951 ms
107,804 KB
testcase_13 AC 782 ms
51,636 KB
testcase_14 AC 3,173 ms
161,764 KB
testcase_15 AC 6 ms
6,676 KB
testcase_16 AC 567 ms
43,864 KB
testcase_17 AC 421 ms
33,696 KB
testcase_18 AC 256 ms
23,980 KB
testcase_19 AC 1,975 ms
104,752 KB
testcase_20 AC 3,571 ms
164,708 KB
testcase_21 AC 915 ms
59,860 KB
testcase_22 AC 1,060 ms
62,052 KB
testcase_23 AC 394 ms
30,124 KB
testcase_24 AC 3,134 ms
153,688 KB
testcase_25 AC 1,573 ms
92,256 KB
testcase_26 AC 93 ms
14,208 KB
testcase_27 AC 1,357 ms
78,344 KB
testcase_28 AC 954 ms
61,792 KB
testcase_29 AC 880 ms
60,716 KB
testcase_30 AC 1,925 ms
104,548 KB
testcase_31 AC 1,962 ms
105,092 KB
testcase_32 AC 2,384 ms
119,720 KB
testcase_33 AC 1,677 ms
93,924 KB
testcase_34 AC 2,868 ms
143,052 KB
testcase_35 AC 2,307 ms
118,800 KB
testcase_36 AC 2,757 ms
140,812 KB
testcase_37 AC 499 ms
42,496 KB
testcase_38 AC 2,968 ms
149,024 KB
testcase_39 AC 2,588 ms
134,112 KB
testcase_40 AC 2,608 ms
136,912 KB
testcase_41 AC 3,909 ms
187,548 KB
testcase_42 AC 3,479 ms
168,720 KB
testcase_43 AC 3,694 ms
175,744 KB
testcase_44 TLE -
testcase_45 TLE -
testcase_46 AC 3,895 ms
185,156 KB
testcase_47 TLE -
testcase_48 TLE -
testcase_49 TLE -
testcase_50 TLE -
testcase_51 TLE -
testcase_52 TLE -
testcase_53 TLE -
testcase_54 TLE -
testcase_55 TLE -
testcase_56 TLE -
testcase_57 TLE -
testcase_58 TLE -
testcase_59 AC 3,787 ms
179,964 KB
testcase_60 TLE -
testcase_61 AC 2 ms
6,676 KB
testcase_62 AC 2 ms
6,676 KB
testcase_63 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <variant>

#define rep2(i,k,n) for(i64 i=(i64)(k);i<(i64)(n);i++)
#define rep(i,n) rep2(i,0,n)
#define all(x) begin(x),end(x)
#ifdef ENV_LOCAL
#define dump if (1) cerr
#else
#define dump if (0) cerr
#endif

using namespace std;
using namespace std::string_literals;

using i32 = int32_t;
using i64 = int64_t;
using f64 = double;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;

//using namespace harudake;

vector<unordered_map<i64,i64>> memo;

i64 solve(i64 n, i64 k) {
  if (memo[n].count(k)) {
    return memo[n].at(k);
  }
  if (k == 0) {
    return 0;
  }
  if (n == 1) {
    return 2;
  }
  i64 ans = solve(n-1, k) + solve(n-1, k/n);
  memo[n][k] = ans;
  return ans;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  i64 n,k;
  cin>>n>>k;
  memo.resize(n+1);
  cout<<solve(n,k)-1<<endl;
  return 0;
}
0