結果
問題 | No.2244 Integer Complete |
ユーザー | 👑 rin204 |
提出日時 | 2024-04-28 15:20:21 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 92 ms / 2,000 ms |
コード長 | 2,760 bytes |
コンパイル時間 | 1,150 ms |
コンパイル使用メモリ | 82,128 KB |
実行使用メモリ | 83,408 KB |
最終ジャッジ日時 | 2024-11-17 08:17:11 |
合計ジャッジ時間 | 6,048 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 40 ms
53,104 KB |
testcase_01 | AC | 40 ms
53,084 KB |
testcase_02 | AC | 41 ms
54,780 KB |
testcase_03 | AC | 40 ms
53,548 KB |
testcase_04 | AC | 40 ms
53,220 KB |
testcase_05 | AC | 41 ms
54,876 KB |
testcase_06 | AC | 41 ms
52,528 KB |
testcase_07 | AC | 42 ms
53,904 KB |
testcase_08 | AC | 40 ms
52,984 KB |
testcase_09 | AC | 41 ms
53,852 KB |
testcase_10 | AC | 40 ms
53,252 KB |
testcase_11 | AC | 40 ms
52,804 KB |
testcase_12 | AC | 40 ms
53,208 KB |
testcase_13 | AC | 41 ms
54,044 KB |
testcase_14 | AC | 39 ms
52,464 KB |
testcase_15 | AC | 40 ms
53,144 KB |
testcase_16 | AC | 40 ms
52,928 KB |
testcase_17 | AC | 62 ms
75,552 KB |
testcase_18 | AC | 61 ms
75,572 KB |
testcase_19 | AC | 63 ms
78,460 KB |
testcase_20 | AC | 87 ms
80,468 KB |
testcase_21 | AC | 85 ms
82,192 KB |
testcase_22 | AC | 65 ms
73,840 KB |
testcase_23 | AC | 55 ms
68,616 KB |
testcase_24 | AC | 86 ms
77,680 KB |
testcase_25 | AC | 80 ms
77,680 KB |
testcase_26 | AC | 58 ms
73,048 KB |
testcase_27 | AC | 92 ms
83,408 KB |
testcase_28 | AC | 65 ms
78,128 KB |
testcase_29 | AC | 92 ms
83,316 KB |
testcase_30 | AC | 87 ms
83,336 KB |
testcase_31 | AC | 55 ms
68,968 KB |
testcase_32 | AC | 54 ms
69,976 KB |
testcase_33 | AC | 49 ms
62,800 KB |
testcase_34 | AC | 55 ms
69,344 KB |
testcase_35 | AC | 58 ms
71,472 KB |
testcase_36 | AC | 58 ms
71,744 KB |
testcase_37 | AC | 61 ms
74,704 KB |
testcase_38 | AC | 59 ms
72,000 KB |
testcase_39 | AC | 56 ms
71,252 KB |
testcase_40 | AC | 56 ms
69,352 KB |
testcase_41 | AC | 57 ms
73,256 KB |
testcase_42 | AC | 57 ms
73,328 KB |
testcase_43 | AC | 59 ms
74,008 KB |
testcase_44 | AC | 58 ms
71,600 KB |
testcase_45 | AC | 59 ms
71,224 KB |
testcase_46 | AC | 62 ms
73,844 KB |
testcase_47 | AC | 60 ms
72,652 KB |
testcase_48 | AC | 56 ms
70,184 KB |
testcase_49 | AC | 54 ms
70,788 KB |
testcase_50 | AC | 56 ms
70,616 KB |
testcase_51 | AC | 61 ms
76,708 KB |
testcase_52 | AC | 63 ms
76,544 KB |
testcase_53 | AC | 58 ms
73,212 KB |
testcase_54 | AC | 57 ms
72,624 KB |
testcase_55 | AC | 51 ms
65,956 KB |
testcase_56 | AC | 52 ms
66,740 KB |
testcase_57 | AC | 48 ms
61,764 KB |
testcase_58 | AC | 55 ms
70,104 KB |
testcase_59 | AC | 56 ms
71,156 KB |
ソースコード
from math import gcd def isprime(n): if n <= 1: return False elif n == 2: return True elif n % 2 == 0: return False A = [2, 325, 9375, 28178, 450775, 9780504, 1795265022] s = 0 d = n - 1 while d % 2 == 0: s += 1 d >>= 1 for a in A: if a % n == 0: return True x = pow(a, d, n) if x != 1: for t in range(s): if x == n - 1: break x = x * x % n else: return False return True def pollard(n): if n % 2 == 0: return 2 if isprime(n): return n f = lambda x: (x * x + 1) % n step = 0 while 1: step += 1 x = step y = f(x) while 1: p = gcd(y - x + n, n) if p == 0 or p == n: break if p != 1: return p x = f(x) y = f(f(y)) def primefact(n): if n == 1: return [] p = pollard(n) if p == n: return [p] left = primefact(p) right = primefact(n // p) left += right return sorted(left) def primedict(n): P = primefact(n) ret = {} for p in P: ret[p] = ret.get(p, 0) + 1 return ret def divisor_lst(n): if n == 1: return [1] primes = primefact(n) primes.append(primes[-1] + 1) bef = primes[0] cnt = 0 ret = [1] for p in primes: if p == bef: cnt += 1 else: times = bef le = len(ret) for _ in range(cnt): for i in range(le): ret.append(ret[i] * times) times *= bef bef = p cnt = 1 ret.sort() return ret n, m = map(int, input().split()) A = list(map(int, input().split())) B = list(map(int, input().split())) ma = max(*A, *B) ca = [False] * (ma + 2) cb = [False] * (ma + 2) for a in A: ca[a] = True for b in B: cb[b] = True if not ca[1] or not cb[1]: print(1) exit() for i in range(1, ma + 2): if ca[i] or cb[i]: continue x = i * i while 1: divs = divisor_lst(x) ok = False for d in divs: a = int(d**0.5) while a * a < d: a += 1 while a * a > d: a -= 1 b = int((x // d) ** 0.5) while b * b < x // d: b += 1 while b * b > x // d: b -= 1 if (ca[a] and cb[b]) or (ca[b] and cb[a]): ok = True break if ok: x += 1 continue else: print(x) exit()