結果

問題 No.1809 Divide NCK
ユーザー 👑 ygussanyygussany
提出日時 2021-12-29 14:22:14
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 716 bytes
コンパイル時間 180 ms
コンパイル使用メモリ 30,720 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-14 19:50:09
合計ジャッジ時間 1,960 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 1 ms
6,944 KB
testcase_04 WA -
testcase_05 AC 1 ms
6,940 KB
testcase_06 AC 1 ms
6,944 KB
testcase_07 WA -
testcase_08 AC 1 ms
6,944 KB
testcase_09 AC 1 ms
6,940 KB
testcase_10 AC 1 ms
6,944 KB
testcase_11 AC 1 ms
6,940 KB
testcase_12 AC 1 ms
6,940 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 60 ms
6,940 KB
testcase_17 AC 3 ms
6,940 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 1 ms
6,944 KB
testcase_21 AC 1 ms
6,944 KB
testcase_22 AC 1 ms
6,940 KB
testcase_23 AC 1 ms
6,940 KB
testcase_24 AC 1 ms
6,944 KB
testcase_25 AC 1 ms
6,940 KB
testcase_26 AC 1 ms
6,940 KB
testcase_27 AC 1 ms
6,940 KB
testcase_28 WA -
testcase_29 AC 34 ms
6,940 KB
testcase_30 AC 2 ms
6,944 KB
testcase_31 AC 1 ms
6,944 KB
testcase_32 AC 1 ms
6,940 KB
testcase_33 AC 6 ms
6,940 KB
testcase_34 AC 2 ms
6,944 KB
testcase_35 WA -
testcase_36 AC 1 ms
6,940 KB
testcase_37 AC 1 ms
6,940 KB
testcase_38 AC 1 ms
6,940 KB
testcase_39 AC 1 ms
6,944 KB
testcase_40 WA -
testcase_41 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

void chmin(long long* a, long long b)
{
	if (*a > b) *a = b;
}

long long count(long long N, long long M)
{
	int i, j, k, m[100] = {};
	long long p[100];
	for (i = 2, k = 0; M / i >= i; i++) {
		if (M % i == 0) {
			p[k] = i;
			while (M % i == 0) {
				M /= i;
				m[k]++;
			}
			k++;
		}
	}
	if (M > 1) {
		p[k] = M;
		m[k++] = 1;
	}
	
	long long ans = 1LL << 60, tmp, X;
	for (i = 0; i < k; i++) {
		for (X = p[i], tmp = 0; 1; X *= p[i]) {
			tmp += N / X;
			if (X > N / p[i]) break;
		}
		chmin(&ans, tmp);
	}
	return ans;
}

int main()
{
	long long N, K, M;
	scanf("%lld %lld %lld", &N, &K, &M);
	printf("%lld\n", count(N, M) - count(N - K, M) - count(K, M));
	fflush(stdout);
	return 0;
}
0