結果

問題 No.1383 Numbers of Product
ユーザー 👑 ygussanyygussany
提出日時 2021-02-07 21:51:39
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 715 ms / 2,000 ms
コード長 1,180 bytes
コンパイル時間 341 ms
コンパイル使用メモリ 31,104 KB
実行使用メモリ 33,920 KB
最終ジャッジ日時 2024-05-02 10:19:19
合計ジャッジ時間 19,959 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
9,728 KB
testcase_01 AC 3 ms
9,856 KB
testcase_02 AC 3 ms
9,728 KB
testcase_03 AC 4 ms
9,600 KB
testcase_04 AC 3 ms
9,856 KB
testcase_05 AC 4 ms
9,728 KB
testcase_06 AC 3 ms
9,856 KB
testcase_07 AC 408 ms
24,548 KB
testcase_08 AC 418 ms
24,320 KB
testcase_09 AC 527 ms
27,904 KB
testcase_10 AC 706 ms
33,792 KB
testcase_11 AC 692 ms
33,408 KB
testcase_12 AC 704 ms
33,664 KB
testcase_13 AC 666 ms
32,640 KB
testcase_14 AC 563 ms
29,184 KB
testcase_15 AC 448 ms
25,344 KB
testcase_16 AC 698 ms
33,408 KB
testcase_17 AC 6 ms
9,728 KB
testcase_18 AC 7 ms
9,728 KB
testcase_19 AC 7 ms
9,728 KB
testcase_20 AC 6 ms
9,600 KB
testcase_21 AC 6 ms
9,600 KB
testcase_22 AC 7 ms
9,728 KB
testcase_23 AC 7 ms
9,728 KB
testcase_24 AC 6 ms
9,728 KB
testcase_25 AC 6 ms
9,600 KB
testcase_26 AC 6 ms
9,728 KB
testcase_27 AC 27 ms
9,600 KB
testcase_28 AC 37 ms
9,984 KB
testcase_29 AC 537 ms
28,416 KB
testcase_30 AC 710 ms
33,920 KB
testcase_31 AC 28 ms
9,728 KB
testcase_32 AC 153 ms
14,720 KB
testcase_33 AC 27 ms
9,600 KB
testcase_34 AC 28 ms
9,728 KB
testcase_35 AC 647 ms
31,872 KB
testcase_36 AC 613 ms
30,720 KB
testcase_37 AC 709 ms
33,920 KB
testcase_38 AC 708 ms
33,792 KB
testcase_39 AC 713 ms
33,920 KB
testcase_40 AC 712 ms
33,920 KB
testcase_41 AC 711 ms
33,920 KB
testcase_42 AC 709 ms
33,920 KB
testcase_43 AC 711 ms
33,920 KB
testcase_44 AC 715 ms
33,920 KB
testcase_45 AC 714 ms
33,920 KB
testcase_46 AC 7 ms
9,600 KB
testcase_47 AC 696 ms
33,280 KB
testcase_48 AC 702 ms
33,536 KB
testcase_49 AC 711 ms
33,920 KB
testcase_50 AC 714 ms
33,792 KB
testcase_51 AC 6 ms
9,600 KB
testcase_52 AC 6 ms
9,600 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

#define HASH 1000003

typedef struct List {
	struct List *next;
	int num;
	long long v;
} list;

int main()
{
	long long N, K, M;
	scanf("%lld %lld %lld", &N, &K, &M);
	
	int h, i, n = 0, count = 0, ans = 0;
	long long A, B, tmp, l, r, m;
	list *hash[HASH] = {}, d[5000000], *p;
	for (A = 1; A <= 1000000; A++) {
		if (A + K > N / A) break;
		for (B = 2, tmp = A * (A + K); A + B * K <= N / tmp; B++) {
			tmp *= A + B * K;
			h = tmp % HASH;
			for (p = hash[h]; p != NULL; p = p->next) if (p->v == tmp) break;
			if (p != NULL) p->num++;
			else {
				d[n].v = tmp;
				d[n].num = 1;
				
				l = 1;
				r = 1000000000;
				while (l < r) {
					m = (l + r) / 2;
					if (m + K < tmp / m) l = m + 1;
					else r = m;
				}
				if (l * (l + K) == tmp) {
					d[n].num++;
					count++;
				}
				
				d[n].next = hash[h];
				hash[h] = &(d[n++]);
			}
		}
	}
	for (i = 0; i < n; i++) if (d[i].num == M) ans++;
	if (M >= 2) {
		printf("%d\n", ans);
		fflush(stdout);
		return 0;
	}
	
	l = 0;
	r = 1000000000;
	while (l < r) {
		m = (l + r + 1) / 2;
		if (m + K <= N / m) l = m;
		else r = m - 1;
	}
	printf("%d\n", ans - count + l);
	fflush(stdout);
	return 0;
}
0