結果
問題 |
No.2244 Integer Complete
|
ユーザー |
![]() |
提出日時 | 2025-04-16 01:09:50 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,236 bytes |
コンパイル時間 | 371 ms |
コンパイル使用メモリ | 81,740 KB |
実行使用メモリ | 93,792 KB |
最終ジャッジ日時 | 2025-04-16 01:11:31 |
合計ジャッジ時間 | 5,294 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 TLE * 1 -- * 40 |
ソースコード
import bisect import math def main(): import sys input = sys.stdin.read().split() ptr = 0 N, M = int(input[ptr]), int(input[ptr+1]) ptr += 2 A = list(map(int, input[ptr:ptr+N])) ptr += N B = list(map(int, input[ptr:ptr+M])) ptr += M A_sorted = A B_sorted = B def is_in_A(x): s = math.isqrt(x) idx = bisect.bisect_left(A_sorted, s) if idx < len(A_sorted) and A_sorted[idx] == s: return s**2 <= x <= (s + 1)**2 - 1 return False def is_in_B(x): s = math.isqrt(x) idx = bisect.bisect_left(B_sorted, s) if idx < len(B_sorted) and B_sorted[idx] == s: return s**2 <= x <= (s + 1)**2 - 1 return False k = 1 while True: divisors = set() for i in range(1, int(math.isqrt(k)) + 1): if k % i == 0: divisors.add(i) divisors.add(k // i) found = False for d in divisors: if (is_in_A(d) and is_in_B(k // d)) or (is_in_B(d) and is_in_A(k // d)): found = True break if not found: print(k) return k += 1 if __name__ == '__main__': main()