結果
| 問題 | No.683 Two Operations No.3 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-05-11 22:54:40 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 143 ms / 2,000 ms |
| コード長 | 1,083 bytes |
| 記録 | |
| コンパイル時間 | 4,318 ms |
| コンパイル使用メモリ | 79,876 KB |
| 実行使用メモリ | 54,488 KB |
| 最終ジャッジ日時 | 2024-06-28 09:55:33 |
| 合計ジャッジ時間 | 7,089 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 16 |
ソースコード
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);
}
}
}