結果

問題 No.2120 場合の数の下8桁
ユーザー kiliarinkiliarin
提出日時 2022-11-04 22:42:31
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 82 ms / 2,000 ms
コード長 839 bytes
コンパイル時間 301 ms
コンパイル使用メモリ 33,460 KB
実行使用メモリ 15,416 KB
最終ジャッジ日時 2023-09-26 01:12:27
合計ジャッジ時間 2,823 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
15,328 KB
testcase_01 AC 78 ms
15,412 KB
testcase_02 AC 77 ms
15,388 KB
testcase_03 AC 76 ms
15,416 KB
testcase_04 AC 79 ms
15,272 KB
testcase_05 AC 73 ms
15,396 KB
testcase_06 AC 78 ms
15,408 KB
testcase_07 AC 69 ms
15,328 KB
testcase_08 AC 69 ms
15,328 KB
testcase_09 AC 76 ms
15,376 KB
testcase_10 AC 78 ms
15,348 KB
testcase_11 AC 79 ms
15,388 KB
testcase_12 AC 76 ms
15,392 KB
testcase_13 AC 76 ms
15,344 KB
testcase_14 AC 77 ms
15,404 KB
testcase_15 AC 80 ms
15,332 KB
testcase_16 AC 78 ms
15,348 KB
testcase_17 AC 81 ms
15,340 KB
testcase_18 AC 70 ms
15,416 KB
testcase_19 AC 82 ms
15,396 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define LOG(FMT...) fprintf(stderr, FMT)

typedef long long LL;
const int N = 10000005, PC = 664600;
const int mod = 100000000;

int pr[PC], cnt;
bool ws[N];

void sieve() {
	for (int i = 2; i < N; ++i) {
		if (!ws[i]) {
			pr[cnt++] = i;
		}
		for (int j = 0; i * pr[j] < N; ++j) {
			ws[i * pr[j]] = true;
			if (i % pr[j] == 0) {
				break;
			}
		}
	}
}

int p;

int calc(int x) {
	int k = 0;
	while (x) {
		k += x /= p;
	}
	return k;
}

int main() {
	sieve();
	int n, m;
	scanf("%d%d", &n, &m);
	if (n < m) {
		printf("%08d\n", 0);
		return 0;
	}
	int r = 1;
	for (int i = 0; i < cnt; ++i) {
		p = pr[i];
		int k = calc(n) - calc(m) - calc(n - m);
		while (k) {
			if (k & 1) r = p * (LL)r % mod;
			p = p * (LL)p % mod;
			k >>= 1;
		}
	}
	printf("%08d\n", r);
	return 0;
}
0