結果

問題 No.1532 Different Products
ユーザー nok0nok0
提出日時 2021-06-04 21:35:53
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3,331 ms / 4,000 ms
コード長 1,007 bytes
コンパイル時間 1,224 ms
コンパイル使用メモリ 94,080 KB
実行使用メモリ 195,116 KB
最終ジャッジ日時 2024-04-30 02:04:32
合計ジャッジ時間 110,729 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 479 ms
42,472 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 3 ms
5,376 KB
testcase_08 AC 5 ms
5,376 KB
testcase_09 AC 77 ms
13,212 KB
testcase_10 AC 541 ms
46,328 KB
testcase_11 AC 441 ms
42,468 KB
testcase_12 AC 1,604 ms
103,596 KB
testcase_13 AC 689 ms
51,064 KB
testcase_14 AC 2,717 ms
169,256 KB
testcase_15 AC 8 ms
5,376 KB
testcase_16 AC 479 ms
44,924 KB
testcase_17 AC 417 ms
42,340 KB
testcase_18 AC 248 ms
24,680 KB
testcase_19 AC 1,532 ms
101,160 KB
testcase_20 AC 2,776 ms
171,812 KB
testcase_21 AC 721 ms
57,084 KB
testcase_22 AC 801 ms
59,000 KB
testcase_23 AC 320 ms
29,672 KB
testcase_24 AC 2,587 ms
164,648 KB
testcase_25 AC 1,303 ms
92,200 KB
testcase_26 AC 98 ms
14,372 KB
testcase_27 AC 1,099 ms
83,112 KB
testcase_28 AC 790 ms
58,876 KB
testcase_29 AC 729 ms
57,084 KB
testcase_30 AC 1,525 ms
101,164 KB
testcase_31 AC 1,510 ms
101,552 KB
testcase_32 AC 1,671 ms
112,300 KB
testcase_33 AC 1,294 ms
94,124 KB
testcase_34 AC 2,397 ms
164,776 KB
testcase_35 AC 1,713 ms
111,664 KB
testcase_36 AC 2,366 ms
164,656 KB
testcase_37 AC 428 ms
43,388 KB
testcase_38 AC 2,458 ms
164,652 KB
testcase_39 AC 2,228 ms
164,604 KB
testcase_40 AC 2,241 ms
164,652 KB
testcase_41 AC 3,156 ms
190,760 KB
testcase_42 AC 2,816 ms
175,140 KB
testcase_43 AC 2,950 ms
180,900 KB
testcase_44 AC 3,218 ms
192,808 KB
testcase_45 AC 3,166 ms
193,064 KB
testcase_46 AC 3,176 ms
188,712 KB
testcase_47 AC 2,978 ms
194,472 KB
testcase_48 AC 2,918 ms
192,812 KB
testcase_49 AC 3,018 ms
193,708 KB
testcase_50 AC 2,963 ms
192,548 KB
testcase_51 AC 2,945 ms
194,088 KB
testcase_52 AC 2,952 ms
191,404 KB
testcase_53 AC 3,043 ms
194,600 KB
testcase_54 AC 3,215 ms
191,532 KB
testcase_55 AC 3,289 ms
193,324 KB
testcase_56 AC 3,163 ms
188,584 KB
testcase_57 AC 3,157 ms
189,612 KB
testcase_58 AC 3,231 ms
192,172 KB
testcase_59 AC 3,054 ms
184,232 KB
testcase_60 AC 3,331 ms
195,116 KB
testcase_61 AC 2 ms
5,376 KB
testcase_62 AC 2 ms
5,376 KB
testcase_63 AC 3,285 ms
193,324 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/*
この問題は、TLが長いことを利用すると工夫したメモ化全探索で通すことができます
方針としては、大きい値から小さい値の順でdfsを行います
*/

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("popcnt,bmi2,fma,fma4,avx512f,avx512dq,avx512cd,avx512bw,avx512vl")
#include <iostream>
#include <unordered_map>

constexpr long long base = 10000000001;
int n;
long long res, k;
int main() {
	std::cin >> n >> k;
	std::unordered_map<long long, long long> mp;
	auto dfs = [&](auto self, long long nk, int val) -> long long {
		if(val == 0) return 1ll;

		//pairで持つとTLEしたので、適当な数を掛けてlong longひとつに状態を持たせています
		long long key = val * base + nk;
		if(mp[key]) return mp[key];

		//使わない場合と使う場合
		return mp[key] = self(self, nk, val - 1) + (nk / val ? self(self, nk / val, val - 1) : 0);
	};
	std::cout << dfs(dfs, k, n) - 1 << '\n';
	return 0;
}
0