結果

問題 No.643 Two Operations No.2
ユーザー 41Toame
提出日時 2018-04-25 19:14:16
言語 Java
(openjdk 23)
結果
AC  
実行時間 131 ms / 2,000 ms
コード長 551 bytes
コンパイル時間 3,413 ms
コンパイル使用メモリ 74,544 KB
実行使用メモリ 41,188 KB
最終ジャッジ日時 2024-06-27 21:04:35
合計ジャッジ時間 5,781 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class T03 {

    static int opera(int c, int X, int Y) {
        if (c == 12) return 1000;
        else if (X == Y) return c;
        else {
            return Math.min(opera(c + 1, Y, X), opera(c + 1, X + Y, X - Y));
        }
    }
            
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int Y = sc.nextInt();

        int ans = opera(0, X, Y);
        if (ans == 1000) ans = -1;
        System.out.println(ans);
    }
}

        
0