結果

問題 No.683 Two Operations No.3
ユーザー GrenacheGrenache
提出日時 2018-05-11 22:54:40
言語 Java21
(openjdk 21)
結果
AC  
実行時間 132 ms / 2,000 ms
コード長 1,083 bytes
コンパイル時間 4,231 ms
コンパイル使用メモリ 75,436 KB
実行使用メモリ 55,848 KB
最終ジャッジ日時 2023-09-10 18:45:00
合計ジャッジ時間 7,081 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 130 ms
55,560 KB
testcase_01 AC 128 ms
55,736 KB
testcase_02 AC 126 ms
55,768 KB
testcase_03 AC 129 ms
55,500 KB
testcase_04 AC 130 ms
55,764 KB
testcase_05 AC 129 ms
55,572 KB
testcase_06 AC 126 ms
55,848 KB
testcase_07 AC 132 ms
53,776 KB
testcase_08 AC 130 ms
55,456 KB
testcase_09 AC 132 ms
55,676 KB
testcase_10 AC 128 ms
55,732 KB
testcase_11 AC 128 ms
55,788 KB
testcase_12 AC 131 ms
55,452 KB
testcase_13 AC 129 ms
55,508 KB
testcase_14 AC 128 ms
55,748 KB
testcase_15 AC 126 ms
55,796 KB
権限があれば一括ダウンロードができます

ソースコード

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