結果
問題 |
No.2207 pCr検査
|
ユーザー |
![]() |
提出日時 | 2025-04-15 22:54:09 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,530 bytes |
コンパイル時間 | 284 ms |
コンパイル使用メモリ | 81,600 KB |
実行使用メモリ | 52,356 KB |
最終ジャッジ日時 | 2025-04-15 22:55:54 |
合計ジャッジ時間 | 7,033 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | TLE * 1 -- * 29 |
ソースコード
import sys import math def factorize(n): factors = {} while n % 2 == 0: factors[2] = factors.get(2, 0) + 1 n = n // 2 i = 3 while i * i <= n: while n % i == 0: factors[i] = factors.get(i, 0) + 1 n = n // i i += 2 if n > 1: factors[n] = 1 return factors def main(): input = sys.stdin.read().split() idx = 0 k = int(input[idx]) idx += 1 factors = {} for _ in range(k): p = int(input[idx]) e = int(input[idx+1]) factors[p] = e idx += 2 # Check if N is a prime (k=1 and e=1) if len(factors) == 1: p, e = next(iter(factors.items())) if e == 1: print(p, 1) return # Check for r=2 case for p in list(factors.keys()): if factors[p] != 1: continue # Create expected factors expected = factors.copy() expected[p] -= 1 if expected[p] == 0: del expected[p] # Add 2 if 2 in expected: expected[2] += 1 else: expected[2] = 1 # Compute p-1 target = p - 1 if target <= 1: continue # Factorize target actual = factorize(target) # Compare actual and expected if actual == expected and p >= 5: print(p, 2) return # No solution found print(-1, -1) if __name__ == "__main__": main()