結果

問題 No.683 Two Operations No.3
ユーザー GrenacheGrenache
提出日時 2018-05-11 22:47:37
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 1,083 bytes
コンパイル時間 3,653 ms
コンパイル使用メモリ 75,140 KB
実行使用メモリ 57,660 KB
最終ジャッジ日時 2023-09-10 17:42:03
合計ジャッジ時間 8,072 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
57,660 KB
testcase_01 AC 123 ms
56,240 KB
testcase_02 AC 122 ms
55,772 KB
testcase_03 AC 122 ms
54,200 KB
testcase_04 AC 126 ms
55,676 KB
testcase_05 AC 126 ms
56,256 KB
testcase_06 TLE -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;


public class Main_yukicoder683 {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		long a = sc.nextLong();
		long b = sc.nextLong();

		Deque<Long> sta = new ArrayDeque<>();
		Deque<Long> stb = new ArrayDeque<>();
		sta.push(a);
		stb.push(b);
		while (!sta.isEmpty()) {
			long ea = sta.pop();
			long eb = stb.pop();

			if (ea == 0 && eb == 0) {
				pr.println("Yes");
				return;
			}

			if (ea > 0 && eb % 2 == 0) {
				sta.push(ea - 1);
				stb.push(eb / 2);
			}
			if (eb > 0 && ea % 2 == 0) {
				sta.push(ea / 2);
				stb.push(eb - 1);
			}
		}

		pr.println("No");
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(INPUT == null ? System.in : new ByteArrayInputStream(INPUT.getBytes()));
		pr = new Printer(System.out);

		solve();

//		pr.close();
		pr.flush();
//		sc.close();
	}

	static String INPUT = null;

	private static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}
0