結果
| 問題 | No.141 魔法少女コバ |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-09-23 21:38:16 |
| 言語 | Python3 (3.14.7 + numpy 2.5.2 + scipy 1.18.0 + ACL) |
| 結果 |
RE
不安定
|
| 実行時間 | - |
| コード長 | 438 bytes |
| 記録 | |
| コンパイル時間 | 55 ms |
| コンパイル使用メモリ | 14,976 KB |
| 実行使用メモリ | 13,440 KB |
| 最終ジャッジ日時 | 2026-09-22 00:24:37 |
| 合計ジャッジ時間 | 10,145 ms |
|
ジャッジサーバーID (参考情報) |
judge4_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | RE * 1 TLE * 1 -- * 91 |
ソースコード
# -*- 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/N)<1:
temp = M
M = N
N = temp
else:
M -= N
ans += 1
if (M==1 and N==1) or M<0 or N<0:
break
if M==1 and N==1:
print(ans)
else:
print(-1)