結果

問題 No.2207 pCr検査
ユーザー 👑 tatyamtatyam
提出日時 2022-07-13 01:24:15
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 749 ms / 3,000 ms
コード長 685 bytes
コンパイル時間 342 ms
コンパイル使用メモリ 87,168 KB
実行使用メモリ 135,780 KB
最終ジャッジ日時 2023-09-15 16:09:59
合計ジャッジ時間 16,379 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,676 KB
testcase_01 AC 71 ms
71,620 KB
testcase_02 AC 595 ms
105,244 KB
testcase_03 AC 409 ms
97,284 KB
testcase_04 AC 456 ms
97,008 KB
testcase_05 AC 637 ms
112,504 KB
testcase_06 AC 419 ms
87,304 KB
testcase_07 AC 360 ms
91,260 KB
testcase_08 AC 278 ms
88,772 KB
testcase_09 AC 525 ms
104,684 KB
testcase_10 AC 260 ms
78,920 KB
testcase_11 AC 501 ms
102,816 KB
testcase_12 AC 498 ms
106,680 KB
testcase_13 AC 332 ms
95,876 KB
testcase_14 AC 154 ms
82,264 KB
testcase_15 AC 475 ms
97,904 KB
testcase_16 AC 306 ms
94,964 KB
testcase_17 AC 418 ms
97,744 KB
testcase_18 AC 307 ms
85,976 KB
testcase_19 AC 239 ms
88,696 KB
testcase_20 AC 260 ms
84,524 KB
testcase_21 AC 574 ms
113,400 KB
testcase_22 AC 745 ms
135,780 KB
testcase_23 AC 749 ms
135,740 KB
testcase_24 AC 156 ms
79,412 KB
testcase_25 AC 330 ms
92,876 KB
testcase_26 AC 278 ms
87,300 KB
testcase_27 AC 414 ms
91,024 KB
testcase_28 AC 702 ms
117,576 KB
testcase_29 AC 694 ms
117,424 KB
testcase_30 AC 678 ms
117,340 KB
testcase_31 AC 684 ms
117,420 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import math
input = sys.stdin.readline

k = int(input())
N = [tuple(map(int, input().split())) for _ in range(k)]
lgN = sum(math.log(p) * e for p, e in N)
P = N[-1][0]
lg = 0.0
err = math.inf
R = -1
for i in range(P // 2):
    lg += math.log(P - i) - math.log(i + 1)
    if err > abs(lg - lgN):
        err = abs(lg - lgN)
        R = i + 1

def check(R):
    for p, e in N:
        def f(x):
            ans = 0
            while True:
                x //= p
                if x == 0:
                    return ans
                ans += x
        if e != f(P) - f(P - R) - f(R):
            return
    exit(print(P, R))

check(R)
check(R - 1)
check(R + 1)
print(-1, -1)
0