結果

問題 No.1936 Rational Approximation
ユーザー Eki1009Eki1009
提出日時 2022-05-13 21:49:08
言語 PyPy3
(7.3.8)
結果
AC  
実行時間 90 ms / 2,000 ms
コード長 186 bytes
コンパイル時間 384 ms
使用メモリ 75,824 KB
最終ジャッジ日時 2023-02-21 13:58:24
合計ジャッジ時間 2,675 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 88 ms
75,764 KB
testcase_01 AC 88 ms
75,560 KB
testcase_02 AC 89 ms
75,824 KB
testcase_03 AC 87 ms
75,380 KB
testcase_04 AC 87 ms
75,424 KB
testcase_05 AC 88 ms
75,596 KB
testcase_06 AC 87 ms
75,620 KB
testcase_07 AC 88 ms
75,308 KB
testcase_08 AC 88 ms
75,728 KB
testcase_09 AC 88 ms
75,628 KB
testcase_10 AC 88 ms
75,308 KB
testcase_11 AC 89 ms
75,296 KB
testcase_12 AC 89 ms
75,356 KB
testcase_13 AC 88 ms
75,600 KB
testcase_14 AC 90 ms
75,500 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

p,q = map(int,input().split())
x = pow(q,-1,p)
y = (q*x-1)//p
s = (q-y)//q
rp,rq = x+s*p,y+s*q
y = pow(p,-1,q)
x = (p*y-1)//q
t = -(y//q)
lp,lq = x+t*p,y+t*q
ans = lp+lq+rp+rq
print(ans)
0