結果

問題 No.141 魔法少女コバ
ユーザー samplelpmas
提出日時 2017-05-16 10:47:18
言語 Java
(openjdk 23)
結果
AC  
実行時間 883 ms / 5,000 ms
コード長 562 bytes
コンパイル時間 2,101 ms
コンパイル使用メモリ 74,096 KB
実行使用メモリ 54,544 KB
最終ジャッジ日時 2024-09-16 16:12:14
合計ジャッジ時間 20,163 ms
ジャッジサーバーID
(参考情報)
judge4 / judge6
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 93
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int M = sc.nextInt();
        int N = sc.nextInt();

        int count = 0;

        while (M != N) {

            count++;

            if (M > N) {

                M -= N;

            } else {

                int tmp = M;
                M = N;
                N = tmp;

            }

        }

        if (M == 0 || N == 0) {
            count = -1;
        }

        System.out.println(count);

    }

}
0