結果
問題 |
No.2207 pCr検査
|
ユーザー |
![]() |
提出日時 | 2025-06-12 19:57:26 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,132 bytes |
コンパイル時間 | 179 ms |
コンパイル使用メモリ | 81,896 KB |
実行使用メモリ | 61,872 KB |
最終ジャッジ日時 | 2025-06-12 19:59:38 |
合計ジャッジ時間 | 6,890 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | TLE * 1 -- * 29 |
ソースコード
import sys import math def main(): input = sys.stdin.read().split() idx = 0 k = int(input[idx]) idx +=1 primes = [] exponents = [] for _ in range(k): p = int(input[idx]) e = int(input[idx+1]) primes.append(p) exponents.append(e) idx +=2 # Compute N N = 1 for p, e in zip(primes, exponents): N *= p ** e # Check if N is a prime if k == 1 and exponents[0] == 1: print(f"{primes[0]} 1") return # Proceed p_max = primes[-1] e_max = exponents[-1] if e_max != 1: print("-1 -1") return m = N // p_max # Precompute factorials up to 40 factorials = [1] * 41 for i in range(1,41): factorials[i] = factorials[i-1] * i # Check for r from 2 to 40 for r in range(2, 41): product = 1 for i in range(r): term = p_max - i product *= term if product == factorials[r] * m * p_max: print(f"{p_max} {r}") return # No solution found print("-1 -1") return if __name__ == "__main__": main()