結果
| 問題 |
No.141 魔法少女コバ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-09-23 21:56:21 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 529 bytes |
| コンパイル時間 | 337 ms |
| コンパイル使用メモリ | 12,800 KB |
| 実行使用メモリ | 24,648 KB |
| 最終ジャッジ日時 | 2024-11-14 04:50:53 |
| 合計ジャッジ時間 | 507,526 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 9 TLE * 84 |
ソースコード
# -*- coding: utf-8 -*-
import math
M,N = map(int, input().split())
gcd_mn = math.gcd(M, N)
M //= gcd_mn
N //= gcd_mn
ans = 0
# MとNが共に1,もしくは片方が負数となった時点でループを抜ける
while True:
if (M==1 and N==1) or M<0 or N<0:
break
if M<N:
temp = M
M = N
N = temp
ans += 1
else:
# M<NとなるようにMをnN減じる
n = M//N
M -= (n-1)*N
ans += (n-1)
if M==1 and N==1:
print(ans)
else:
print(-1)