結果

問題 No.1936 Rational Approximation
ユーザー Eki1009Eki1009
提出日時 2022-05-13 21:49:08
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 79 ms / 2,000 ms
コード長 186 bytes
コンパイル時間 291 ms
コンパイル使用メモリ 86,684 KB
実行使用メモリ 71,224 KB
最終ジャッジ日時 2023-09-29 06:57:25
合計ジャッジ時間 2,363 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
70,940 KB
testcase_01 AC 79 ms
70,892 KB
testcase_02 AC 75 ms
71,020 KB
testcase_03 AC 76 ms
71,224 KB
testcase_04 AC 75 ms
70,976 KB
testcase_05 AC 76 ms
70,920 KB
testcase_06 AC 73 ms
70,920 KB
testcase_07 AC 73 ms
71,204 KB
testcase_08 AC 72 ms
70,944 KB
testcase_09 AC 72 ms
71,208 KB
testcase_10 AC 77 ms
70,796 KB
testcase_11 AC 73 ms
71,212 KB
testcase_12 AC 75 ms
70,924 KB
testcase_13 AC 74 ms
71,028 KB
testcase_14 AC 75 ms
70,888 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