結果

問題 No.1629 Sorting Integers (SUM of M)
ユーザー pengin_2000pengin_2000
提出日時 2021-08-13 20:39:22
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 17 ms / 2,000 ms
コード長 896 bytes
コンパイル時間 779 ms
コンパイル使用メモリ 31,104 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-14 15:25:24
合計ジャッジ時間 1,351 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 8 ms
6,944 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 3 ms
6,940 KB
testcase_07 AC 10 ms
6,944 KB
testcase_08 AC 8 ms
6,940 KB
testcase_09 AC 9 ms
6,940 KB
testcase_10 AC 8 ms
6,940 KB
testcase_11 AC 6 ms
6,940 KB
testcase_12 AC 8 ms
6,940 KB
testcase_13 AC 10 ms
6,940 KB
testcase_14 AC 7 ms
6,940 KB
testcase_15 AC 9 ms
6,944 KB
testcase_16 AC 10 ms
6,940 KB
testcase_17 AC 17 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>
long long int fact[200005];
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;
}
int main()
{
	long long int n;
	scanf("%lld", &n);
	long long int i, j, k;
	long long int c[10];
	for (i = 1; i < 10; i++)
		scanf("%lld", &c[i]);
	long long int p = 1000000007;
	fact[0] = 1;
	for (i = 1; i <= n; i++)
		fact[i] = fact[i - 1] * i % p;
	long long int v;
	long long int ans = 0;
	for (i = 1; i < 10; i++)
	{
		if (i == 0)
			continue;
		v = fact[n - 1];
		for (j = 1; j < 10; j++)
		{
			if (i == j)
				v = v * modpow(fact[c[j] - 1], p - 2, p) % p;
			else
				v = v * modpow(fact[c[j]], p - 2, p) % p;
		}
		for (j = 0, k = 1; j < n; j++, k = 10 * k % p)
			ans = (ans + i * k % p * v % p) % p;
	}
	printf("%lld\n", ans);
	return 0;
}
0