結果
問題 |
No.2207 pCr検査
|
ユーザー |
![]() |
提出日時 | 2025-06-12 20:01:38 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,138 bytes |
コンパイル時間 | 318 ms |
コンパイル使用メモリ | 81,772 KB |
実行使用メモリ | 268,928 KB |
最終ジャッジ日時 | 2025-06-12 20:05:15 |
合計ジャッジ時間 | 6,843 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | TLE * 1 -- * 29 |
ソースコード
import math import sys def compute_M(factors, p): M = 1 for prime, exp in factors.items(): if prime != p: M *= prime ** exp return M 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 candidates = [p for p in factors if factors[p] == 1] for p in candidates: try: M = compute_M(factors, p) except: continue max_r = min(10**5, p) for r in range(1, max_r + 1): k_val = r - 1 if k_val > p - 1: break numerator = 1 for i in range(k_val): term = p - 1 - i numerator *= term denominator = math.factorial(k_val) try: C = numerator // denominator except: continue if C == M * r: print(p, r) return print(-1, -1) if __name__ == '__main__': main()