結果

問題 No.1532 Different Products
ユーザー 👑 ygussanyygussany
提出日時 2021-06-04 21:10:57
言語 C
(gcc 12.3.0)
結果
MLE  
実行時間 -
コード長 772 bytes
コンパイル時間 331 ms
コンパイル使用メモリ 31,972 KB
実行使用メモリ 814,320 KB
最終ジャッジ日時 2024-04-30 01:06:09
合計ジャッジ時間 5,104 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 24 ms
33,024 KB
testcase_01 MLE -
testcase_02 AC 125 ms
142,464 KB
testcase_03 AC 38 ms
48,768 KB
testcase_04 AC 67 ms
87,808 KB
testcase_05 AC 16 ms
25,344 KB
testcase_06 AC 70 ms
95,616 KB
testcase_07 AC 106 ms
142,464 KB
testcase_08 AC 115 ms
158,080 KB
testcase_09 AC 244 ms
322,176 KB
testcase_10 MLE -
testcase_11 MLE -
testcase_12 MLE -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
testcase_57 -- -
testcase_58 -- -
testcase_59 -- -
testcase_60 -- -
testcase_61 -- -
testcase_62 -- -
testcase_63 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

#define THR 1000000
long long memo[201][THR + 1];

long long recursion(int N, int K)
{
	if (memo[N][K] >= 0) return memo[N][K];
	else if (N == 1) {
		if (K >= 1) memo[N][K] = 2;
		else memo[N][K] = 0;
		return memo[N][K];
	}
	if (K >= N) memo[N][K] = recursion(N - 1, K) + recursion(N - 1, K / N);
	else memo[N][K] = recursion(N - 1, K);
	return memo[N][K];
}

long long DFS(int N, long long K)
{
	if (N == 1) return (K >= 1)? 2: 0;
	else if (K <= THR) return recursion(N, (int)K);
	else return DFS(N - 1, K) + DFS(N - 1, K / N);
}

int main()
{
	int i, j, N;
	long long K;
	scanf("%d %lld\n", &N, &K);
	for (i = 1; i <= N; i++) for (j = 1, memo[i][0] = 0; j <= THR; j++) memo[i][j] = -1;
	printf("%lld\n", DFS(N, K) - 1);
	fflush(stdout);
	return 0;
}
0