結果
問題 |
No.2244 Integer Complete
|
ユーザー |
![]() |
提出日時 | 2023-02-23 20:55:28 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 959 bytes |
コンパイル時間 | 545 ms |
コンパイル使用メモリ | 82,516 KB |
実行使用メモリ | 79,456 KB |
最終ジャッジ日時 | 2024-09-18 02:25:27 |
合計ジャッジ時間 | 5,448 ms |
ジャッジサーバーID (参考情報) |
judge6 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 52 WA * 8 |
ソースコード
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_left(a2, i) - 1 y = bisect.bisect_left(b2, j) - 1 if x < 0 or y < 0: continue 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)