結果

問題 No.1581 Multiple Sequence
ユーザー 👑 ygussanyygussany
提出日時 2021-07-02 22:12:08
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 75 ms / 2,000 ms
コード長 667 bytes
コンパイル時間 1,435 ms
コンパイル使用メモリ 28,768 KB
実行使用メモリ 123,360 KB
最終ジャッジ日時 2023-09-11 22:12:21
合計ジャッジ時間 3,482 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 60 ms
102,940 KB
testcase_03 AC 66 ms
111,520 KB
testcase_04 AC 19 ms
41,544 KB
testcase_05 AC 68 ms
115,612 KB
testcase_06 AC 30 ms
60,656 KB
testcase_07 AC 17 ms
39,460 KB
testcase_08 AC 22 ms
50,040 KB
testcase_09 AC 62 ms
107,176 KB
testcase_10 AC 40 ms
75,492 KB
testcase_11 AC 10 ms
22,524 KB
testcase_12 AC 27 ms
54,256 KB
testcase_13 AC 3 ms
5,576 KB
testcase_14 AC 67 ms
111,532 KB
testcase_15 AC 48 ms
86,044 KB
testcase_16 AC 11 ms
26,800 KB
testcase_17 AC 73 ms
122,004 KB
testcase_18 AC 8 ms
20,368 KB
testcase_19 AC 60 ms
100,832 KB
testcase_20 AC 61 ms
105,128 KB
testcase_21 AC 67 ms
111,448 KB
testcase_22 AC 36 ms
71,152 KB
testcase_23 AC 75 ms
123,360 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

const int Mod = 1000000007;
int div[100001][300] = {};
long long memo[100001];

long long recursion(int M)
{
	if (memo[M] >= 0) return memo[M];
	else memo[M] = 0;

	int i;
	for (i = 0; div[M][i] > 0; i++) memo[M] += recursion((M - div[M][i]) / div[M][i]);
	memo[M] %= Mod;
	return memo[M];
}

int main()
{
	int M;
	scanf("%d", &M);
	
	int i, k, l[100001] = {};
	long long ans = 0;
	for (i = 1; i <= M; i++) for (k = i; k <= M; k += i) div[k][l[k]++] = i;
	for (k = 1, memo[0] = 1; k <= M; k++) memo[k] = -1;
	for (i = 0; div[M][i] > 0; i++) ans += recursion((M - div[M][i]) / div[M][i]);
	printf("%lld\n", ans % Mod);
	fflush(stdout);
	return 0;
}
0