結果

問題 No.2244 Integer Complete
ユーザー shobonvipshobonvip
提出日時 2023-03-08 04:46:27
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 121 ms / 2,000 ms
コード長 991 bytes
コンパイル時間 165 ms
コンパイル使用メモリ 81,796 KB
実行使用メモリ 78,268 KB
最終ジャッジ日時 2023-10-18 05:48:30
合計ジャッジ時間 5,505 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
53,660 KB
testcase_01 AC 41 ms
53,360 KB
testcase_02 AC 42 ms
53,660 KB
testcase_03 AC 40 ms
53,660 KB
testcase_04 AC 40 ms
53,660 KB
testcase_05 AC 42 ms
53,660 KB
testcase_06 AC 39 ms
53,660 KB
testcase_07 AC 38 ms
53,660 KB
testcase_08 AC 39 ms
53,660 KB
testcase_09 AC 40 ms
53,660 KB
testcase_10 AC 39 ms
53,660 KB
testcase_11 AC 39 ms
53,660 KB
testcase_12 AC 41 ms
53,660 KB
testcase_13 AC 39 ms
53,360 KB
testcase_14 AC 39 ms
53,360 KB
testcase_15 AC 39 ms
53,660 KB
testcase_16 AC 40 ms
53,660 KB
testcase_17 AC 55 ms
73,228 KB
testcase_18 AC 56 ms
73,228 KB
testcase_19 AC 66 ms
76,120 KB
testcase_20 AC 117 ms
75,632 KB
testcase_21 AC 119 ms
77,144 KB
testcase_22 AC 87 ms
70,592 KB
testcase_23 AC 53 ms
66,396 KB
testcase_24 AC 113 ms
72,900 KB
testcase_25 AC 96 ms
70,856 KB
testcase_26 AC 56 ms
69,900 KB
testcase_27 AC 120 ms
78,268 KB
testcase_28 AC 76 ms
76,216 KB
testcase_29 AC 121 ms
78,268 KB
testcase_30 AC 112 ms
78,268 KB
testcase_31 AC 54 ms
68,444 KB
testcase_32 AC 54 ms
68,444 KB
testcase_33 AC 51 ms
62,300 KB
testcase_34 AC 65 ms
68,540 KB
testcase_35 AC 57 ms
69,880 KB
testcase_36 AC 60 ms
68,996 KB
testcase_37 AC 76 ms
71,128 KB
testcase_38 AC 60 ms
69,908 KB
testcase_39 AC 55 ms
69,876 KB
testcase_40 AC 54 ms
68,444 KB
testcase_41 AC 56 ms
70,612 KB
testcase_42 AC 55 ms
70,592 KB
testcase_43 AC 63 ms
72,664 KB
testcase_44 AC 55 ms
69,876 KB
testcase_45 AC 56 ms
69,876 KB
testcase_46 AC 72 ms
72,024 KB
testcase_47 AC 66 ms
72,016 KB
testcase_48 AC 54 ms
69,868 KB
testcase_49 AC 51 ms
69,732 KB
testcase_50 AC 53 ms
69,868 KB
testcase_51 AC 56 ms
73,032 KB
testcase_52 AC 62 ms
75,072 KB
testcase_53 AC 53 ms
71,576 KB
testcase_54 AC 52 ms
71,576 KB
testcase_55 AC 52 ms
66,396 KB
testcase_56 AC 50 ms
64,348 KB
testcase_57 AC 47 ms
62,132 KB
testcase_58 AC 55 ms
68,992 KB
testcase_59 AC 55 ms
69,540 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import bisect

def makediv(n):
	lower_divisors , upper_divisors = [], []
	i = 1
	while i*i <= n:
		if n % i == 0:
			lower_divisors.append(i)
			if i != n // i:
				upper_divisors.append(n//i)
		i += 1
	return lower_divisors + upper_divisors[::-1]


n, m = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
a2 = [a[i] * a[i] for i in range(n)]
b2 = [b[i] * b[i] for i in range(m)]

if a[0] != 1 or b[0] != 1:
	print(1)
	exit()

c = [0] * 40000
for i in range(n):
	c[a[i]] = 1
for i in range(m):
	c[b[i]] = 1

v = 0
for i in range(1, 40000):
	if c[i] == 0:
		v = i ** 2
		break

k = v
while True:
	mode = 0
	for i in makediv(k):
		j = k // i
		x = bisect.bisect_right(a2, i) - 1
		y = bisect.bisect_right(b2, j) - 1
		if x < 0 or y < 0:
			continue
		#print(k, i, j, a[x], b[y])
		if not a[x] ** 2 <= i < (a[x] + 1) ** 2:
			continue
		if not b[y] ** 2 <= j < (b[y] + 1) ** 2:
			continue
		mode = 1
		break
	if not mode:
		break
	k += 1

print(k)
0