結果

問題 No.683 Two Operations No.3
ユーザー Daigo HIROOKADaigo HIROOKA
提出日時 2018-06-18 23:26:58
言語 Java19
(openjdk 21)
結果
AC  
実行時間 126 ms / 2,000 ms
コード長 564 bytes
コンパイル時間 3,741 ms
コンパイル使用メモリ 72,708 KB
実行使用メモリ 56,396 KB
最終ジャッジ日時 2023-09-13 06:58:57
合計ジャッジ時間 6,609 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
56,076 KB
testcase_01 AC 121 ms
56,076 KB
testcase_02 AC 122 ms
56,396 KB
testcase_03 AC 122 ms
56,320 KB
testcase_04 AC 123 ms
56,108 KB
testcase_05 AC 123 ms
55,628 KB
testcase_06 AC 122 ms
55,536 KB
testcase_07 AC 124 ms
55,832 KB
testcase_08 AC 123 ms
56,280 KB
testcase_09 AC 121 ms
55,820 KB
testcase_10 AC 121 ms
55,880 KB
testcase_11 AC 122 ms
56,032 KB
testcase_12 AC 121 ms
55,856 KB
testcase_13 AC 124 ms
55,856 KB
testcase_14 AC 124 ms
54,304 KB
testcase_15 AC 126 ms
55,988 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class No683{
	static boolean ans = false;
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		long A = sc.nextLong();
		long B = sc.nextLong();

		operate(A, B);
		System.out.println(ans? "Yes": "No");
	}
	private static void operate(long a, long b){
		if(a == 0 || b == 0){
			ans = true;
			return;
		}
		else if(a%2 == 0 && b%2 == 0){
			operate(a/2, b-1);
			operate(a-1, b/2);
		}else if(a%2 == 0 && b%2 != 0){
			operate(a/2, b-1);
		}else if(a%2 != 0 && b%2 == 0){
			operate(a-1, b/2);
		}
	}
}
0