結果

問題 No.683 Two Operations No.3
ユーザー htensaihtensai
提出日時 2020-05-08 16:40:05
言語 Java21
(openjdk 21)
結果
MLE  
実行時間 -
コード長 1,635 bytes
コンパイル時間 2,088 ms
コンパイル使用メモリ 74,516 KB
実行使用メモリ 838,364 KB
最終ジャッジ日時 2023-09-16 08:30:37
合計ジャッジ時間 5,298 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
55,904 KB
testcase_01 AC 127 ms
55,592 KB
testcase_02 AC 125 ms
55,744 KB
testcase_03 AC 125 ms
55,888 KB
testcase_04 AC 125 ms
56,028 KB
testcase_05 AC 127 ms
55,472 KB
testcase_06 MLE -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    static int[] xArr;
    static int[] yArr;
    static int[] cArr;
    static int[][][] dp;
    static int fee;
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		if (check(sc.nextLong(), sc.nextLong())) {
		    System.out.println("Yes");
		} else {
		    System.out.println("No");
		}
	}
	
	static boolean check(long a, long b) {
	    if (a == 0 && b == 0) {
	        return true;
	    }
	    if (a < 0 || b < 0) {
	        return false;
	    }
	    if (a <= Integer.MAX_VALUE && b <= Integer.MAX_VALUE) {
	        return check((int)a, (int)b);
	    }
	    if (a % 2 == 0) {
	        if (b % 2 == 0) {
	            if (check(a / 2, b - 1)) {
	                return true;
	            } else {
	                return check(a - 1, b / 2);
	            }
	        } else {
	            return check(a / 2, b - 1);
	        }
	    } else {
	        if (b % 2 == 0) {
	            return check(a - 1, b / 2);
	        } else {
	            return false;
	        }
	    }
	}

	static boolean check(int a, int b) {
	    if (a == 0 && b == 0) {
	        return true;
	    }
	    if (a < 0 || b < 0) {
	        return false;
	    }
	    if (a % 2 == 0) {
	        if (b % 2 == 0) {
	            if (check(a / 2, b - 1)) {
	                return true;
	            } else {
	                return check(a - 1, b / 2);
	            }
	        } else {
	            return check(a / 2, b - 1);
	        }
	    } else {
	        if (b % 2 == 0) {
	            return check(a - 1, b / 2);
	        } else {
	            return false;
	        }
	    }
	}
    
    
}
0