結果

問題 No.683 Two Operations No.3
ユーザー matsuyoshi30matsuyoshi30
提出日時 2018-05-12 01:08:21
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 716 bytes
コンパイル時間 1,876 ms
コンパイル使用メモリ 71,396 KB
実行使用メモリ 57,808 KB
最終ジャッジ日時 2023-09-10 18:14:35
合計ジャッジ時間 4,656 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 119 ms
55,932 KB
testcase_01 AC 117 ms
55,800 KB
testcase_02 AC 118 ms
55,752 KB
testcase_03 AC 119 ms
56,024 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 118 ms
55,656 KB
testcase_07 AC 119 ms
55,976 KB
testcase_08 AC 120 ms
56,152 KB
testcase_09 WA -
testcase_10 AC 119 ms
55,620 KB
testcase_11 AC 119 ms
56,328 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 119 ms
55,860 KB
testcase_15 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long a = in.nextLong();
        long b = in.nextLong();

        if(a > b) {
            long tmp = a;
            a = b;
            b = tmp;
        }
        boolean ans = rec(a, b);
        if(ans)
            System.out.println("Yes");
        else
            System.out.println("No");
    }

    private static boolean rec(long i, long j) {
        if(i == 0 || j == 0) return true;

        boolean b = false;
        if(i % 2 == 0) {
            b = rec(i / 2, j - 1);
        }
        if(j % 2 == 0) {
            b = rec(i - 1, j / 2);
        }

        return b;
    }
}
0