結果

問題 No.683 Two Operations No.3
ユーザー tentententen
提出日時 2024-03-07 15:11:50
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,631 bytes
コンパイル時間 2,467 ms
コンパイル使用メモリ 78,248 KB
実行使用メモリ 54,012 KB
最終ジャッジ日時 2024-03-07 15:12:00
合計ジャッジ時間 5,144 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 53 ms
51,896 KB
testcase_02 AC 52 ms
53,988 KB
testcase_03 AC 56 ms
53,972 KB
testcase_04 AC 54 ms
53,992 KB
testcase_05 AC 54 ms
53,992 KB
testcase_06 AC 54 ms
53,984 KB
testcase_07 WA -
testcase_08 AC 53 ms
53,972 KB
testcase_09 AC 53 ms
53,972 KB
testcase_10 AC 53 ms
53,984 KB
testcase_11 WA -
testcase_12 AC 54 ms
53,992 KB
testcase_13 AC 53 ms
53,988 KB
testcase_14 WA -
testcase_15 AC 52 ms
54,004 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;
import java.util.function.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        System.out.println(dfw(sc.nextLong(), sc.nextLong()) ? "Yes" : "No");
    }
    
    static boolean dfw(long a, long b) {
        if (a == 0 || b == 0) {
            return true;
        }
        if (a % 2 == 0) {
            if (b % 2 == 0) {
                return dfw(a / 2, b - 1) || dfw(a - 1, b % 2);
            } else {
                return dfw(a / 2, b - 1);
            }
        } else {
            if (b % 2 == 0) {
                return dfw(a - 1, b / 2);
            } else {
                return false;
            }
        }
    }
}
class Scanner {
    BufferedReader br;
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    public Scanner() {
        try {
            br = new BufferedReader(new InputStreamReader(System.in));
        } catch (Exception e) {
            
        }
    }
    
    public int nextInt() {
        return Integer.parseInt(next());
    }
    
    public long nextLong() {
        return Long.parseLong(next());
    }
    
    public double nextDouble() {
        return Double.parseDouble(next());
    }
    
    public String next() {
        try {
            while (!st.hasMoreTokens()) {
                st = new StringTokenizer(br.readLine());
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            return st.nextToken();
        }
    }
    
}
0