結果
問題 |
No.1936 Rational Approximation
|
ユーザー |
|
提出日時 | 2022-05-13 22:54:19 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 500 bytes |
コンパイル時間 | 175 ms |
コンパイル使用メモリ | 82,516 KB |
実行使用メモリ | 53,960 KB |
最終ジャッジ日時 | 2024-07-22 03:09:14 |
合計ジャッジ時間 | 1,446 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 1 |
other | WA * 14 |
ソースコード
#int(input()) #map(int, input().split()) #list(map(int, input().split())) P, Q = map(int, input().split()) def xgcd(a,b): prevx, nextx = 1, 0 prevy, nexty = 0, 1 while b: quotient = a//b nextx, prevx = prevx - quotient * nextx, nextx nexty, prevy = prevy - quotient * nexty, nexty a, b = b, a % b # print(a,b) return prevx, prevy,a x, y, g = xgcd(P, -Q) a, b = divmod(x, Q) x -= Q * a y -= P * a mx = Q - x my = P - y print(x, y, mx, my)