結果

問題 No.643 Two Operations No.2
ユーザー 41Toame41Toame
提出日時 2018-04-25 19:14:16
言語 Java21
(openjdk 21)
結果
AC  
実行時間 127 ms / 2,000 ms
コード長 551 bytes
コンパイル時間 4,402 ms
コンパイル使用メモリ 72,192 KB
実行使用メモリ 56,092 KB
最終ジャッジ日時 2023-09-10 05:29:32
合計ジャッジ時間 7,265 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
55,856 KB
testcase_01 AC 122 ms
55,828 KB
testcase_02 AC 126 ms
56,092 KB
testcase_03 AC 123 ms
55,940 KB
testcase_04 AC 125 ms
55,768 KB
testcase_05 AC 126 ms
55,832 KB
testcase_06 AC 124 ms
55,836 KB
testcase_07 AC 119 ms
55,920 KB
testcase_08 AC 122 ms
55,804 KB
testcase_09 AC 124 ms
56,008 KB
testcase_10 AC 127 ms
55,820 KB
testcase_11 AC 121 ms
56,044 KB
testcase_12 AC 123 ms
55,852 KB
権限があれば一括ダウンロードができます

ソースコード

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