結果

問題 No.1659 Product of Divisors
ユーザー pengin_2000pengin_2000
提出日時 2021-08-27 22:47:19
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 1,056 ms / 2,000 ms
コード長 1,423 bytes
コンパイル時間 299 ms
コンパイル使用メモリ 30,508 KB
実行使用メモリ 55,192 KB
最終ジャッジ日時 2023-08-13 10:05:21
合計ジャッジ時間 3,734 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 27 ms
4,380 KB
testcase_05 AC 118 ms
18,164 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 12 ms
4,384 KB
testcase_09 AC 42 ms
4,376 KB
testcase_10 AC 17 ms
4,376 KB
testcase_11 AC 42 ms
4,376 KB
testcase_12 AC 1,055 ms
55,168 KB
testcase_13 AC 0 ms
4,376 KB
testcase_14 AC 1,056 ms
55,192 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 3 ms
4,376 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 6 ms
4,380 KB
testcase_21 AC 9 ms
4,376 KB
testcase_22 AC 16 ms
4,376 KB
testcase_23 AC 11 ms
4,384 KB
testcase_24 AC 7 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>
long long int modpow(long long int a, long long int n, long long int p)
{
	long long int res = 1;
	while (n > 0)
	{
		if (n % 2 > 0)
			res = res * a % p;
		a = a * a % p;
		n /= 2;
	}
	return res;
}
long long int conb(long long int n, long long int r, long long int p)
{
	long long int res = 1, i;
	for (i = 1; i <= r; i++)
	{
		res = res * ((n - i + 1) % p) % p;
		res = res * modpow(i, p - 2, p) % p;
	}
	return res;
}
int main()
{
	long long int n, k;
	scanf("%lld %lld", &n, &k);
	long long int a[100003], b[100003], aa, bb;
	long long int i, j, l;
	aa = bb = 0;
	for (i = 1; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			a[aa] = i;
			aa++;
			if (i * i < n)
			{
				b[bb] = n / i;
				bb++;
			}
		}
	}
	while (bb > 0)
	{
		bb--;
		a[aa] = b[bb];
		aa++;
	}
	long long int count = 0;
	for (i = 2, j = n; i * i <= j; i++)
	{
		while (j % i == 0)
		{
			count++;
			j /= i;
		}
	}
	if (j > 1)
		count++;
	long long int p = 1000000007;
	long long int dp[10000][1000];
	for (i = 1; i < aa; i++)
	{
		dp[i][0] = 1;
		for (j = 1; j < count; j++)
			dp[i][j] = 0;
		for (j = 1; j < i; j++)
			if (a[i] % a[j] == 0)
				for (l = 0; l < count - 1; l++)
					dp[i][l + 1] = (dp[i][l + 1] + dp[j][l]) % p;
	}
	if (count > k)
		count = k;
	long long int ans = 1;
	for (i = 1; i < aa; i++)
		for (j = 0; j < count; j++)
			ans = (ans + conb(k, j + 1, p) * dp[i][j] % p) % p;
	printf("%lld\n", ans);
	return 0;
}
0