結果

問題 No.1383 Numbers of Product
ユーザー 👑 ygussanyygussany
提出日時 2021-02-07 21:51:39
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 635 ms / 2,000 ms
コード長 1,180 bytes
コンパイル時間 130 ms
コンパイル使用メモリ 30,416 KB
実行使用メモリ 35,428 KB
最終ジャッジ日時 2023-08-14 22:13:57
合計ジャッジ時間 17,886 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
10,436 KB
testcase_01 AC 3 ms
10,516 KB
testcase_02 AC 3 ms
10,756 KB
testcase_03 AC 3 ms
9,752 KB
testcase_04 AC 3 ms
9,636 KB
testcase_05 AC 3 ms
10,832 KB
testcase_06 AC 3 ms
10,168 KB
testcase_07 AC 383 ms
24,708 KB
testcase_08 AC 372 ms
24,616 KB
testcase_09 AC 469 ms
29,468 KB
testcase_10 AC 628 ms
34,376 KB
testcase_11 AC 620 ms
34,860 KB
testcase_12 AC 632 ms
34,076 KB
testcase_13 AC 614 ms
32,812 KB
testcase_14 AC 511 ms
29,320 KB
testcase_15 AC 410 ms
25,620 KB
testcase_16 AC 628 ms
34,100 KB
testcase_17 AC 4 ms
9,664 KB
testcase_18 AC 4 ms
10,580 KB
testcase_19 AC 2 ms
10,072 KB
testcase_20 AC 3 ms
10,360 KB
testcase_21 AC 3 ms
10,436 KB
testcase_22 AC 3 ms
9,820 KB
testcase_23 AC 3 ms
9,928 KB
testcase_24 AC 3 ms
10,204 KB
testcase_25 AC 4 ms
9,964 KB
testcase_26 AC 3 ms
11,448 KB
testcase_27 AC 24 ms
10,480 KB
testcase_28 AC 33 ms
11,344 KB
testcase_29 AC 489 ms
29,648 KB
testcase_30 AC 628 ms
34,124 KB
testcase_31 AC 24 ms
11,088 KB
testcase_32 AC 135 ms
15,168 KB
testcase_33 AC 24 ms
10,376 KB
testcase_34 AC 25 ms
10,864 KB
testcase_35 AC 569 ms
32,256 KB
testcase_36 AC 539 ms
31,428 KB
testcase_37 AC 630 ms
34,924 KB
testcase_38 AC 632 ms
34,892 KB
testcase_39 AC 629 ms
34,368 KB
testcase_40 AC 635 ms
35,240 KB
testcase_41 AC 621 ms
34,648 KB
testcase_42 AC 626 ms
34,448 KB
testcase_43 AC 633 ms
34,184 KB
testcase_44 AC 613 ms
35,352 KB
testcase_45 AC 625 ms
35,428 KB
testcase_46 AC 4 ms
11,212 KB
testcase_47 AC 606 ms
34,068 KB
testcase_48 AC 621 ms
33,760 KB
testcase_49 AC 621 ms
34,952 KB
testcase_50 AC 631 ms
34,452 KB
testcase_51 AC 3 ms
11,124 KB
testcase_52 AC 2 ms
10,172 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