結果

問題 No.1659 Product of Divisors
ユーザー 👑 ygussanyygussany
提出日時 2021-08-09 09:23:35
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 8 ms / 2,000 ms
コード長 854 bytes
コンパイル時間 196 ms
コンパイル使用メモリ 30,076 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-13 07:26:02
合計ジャッジ時間 1,436 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 0 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 0 ms
4,376 KB
testcase_09 AC 0 ms
4,376 KB
testcase_10 AC 6 ms
4,376 KB
testcase_11 AC 0 ms
4,380 KB
testcase_12 AC 0 ms
4,376 KB
testcase_13 AC 0 ms
4,376 KB
testcase_14 AC 0 ms
4,376 KB
testcase_15 AC 0 ms
4,376 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 0 ms
4,380 KB
testcase_19 AC 0 ms
4,380 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 8 ms
4,376 KB
testcase_23 AC 0 ms
4,376 KB
testcase_24 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

const int Mod = 1000000007;

long long div_mod(long long x, long long y, long long z)
{
	if (x % y == 0) return x / y;
	else return (div_mod((1 + x / y) * y - x, (z % y), y) * z + x) / y;
}

long long combination(long long n, int k)
{
	if (n <= 1 || k == 0) return 1;
	
	long long i, x, y;
	for (i = n, x = 1; i >= n - k + 1; i--) x = x * (i % Mod) % Mod;
	for (i = 2, y = 1; i <= k; i++) y = y * i % Mod;
	return div_mod(x, y, Mod);
}

int main()
{
	long long N, K;
	scanf("%lld %lld", &N, &K);
	
	int i, j, k = 0, m[100] = {};
	long long p;
	for (p = 2; p * p <= N; p++) {
		if (N % p != 0) continue;
		while (N % p == 0) {
			m[k]++;
			N /= p;
		}
		k++;
	}
	if (N >= 2) m[k++] = 1;
	
	long long ans = 1;
	for (i = 0; i < k; i++) ans = ans * combination(K + m[i], m[i]) % Mod;
	printf("%lld\n", ans);
	fflush(stdout);
	return 0;
}
0