結果
問題 |
No.683 Two Operations No.3
|
ユーザー |
![]() |
提出日時 | 2024-03-07 15:11:50 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,631 bytes |
コンパイル時間 | 1,894 ms |
コンパイル使用メモリ | 78,944 KB |
実行使用メモリ | 50,612 KB |
最終ジャッジ日時 | 2024-09-29 18:40:01 |
合計ジャッジ時間 | 3,435 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 12 WA * 4 |
ソースコード
import java.io.*; import java.util.*; import java.util.function.*; import java.util.stream.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); System.out.println(dfw(sc.nextLong(), sc.nextLong()) ? "Yes" : "No"); } static boolean dfw(long a, long b) { if (a == 0 || b == 0) { return true; } if (a % 2 == 0) { if (b % 2 == 0) { return dfw(a / 2, b - 1) || dfw(a - 1, b % 2); } else { return dfw(a / 2, b - 1); } } else { if (b % 2 == 0) { return dfw(a - 1, b / 2); } else { return false; } } } } class Scanner { BufferedReader br; StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); public Scanner() { try { br = new BufferedReader(new InputStreamReader(System.in)); } catch (Exception e) { } } public int nextInt() { return Integer.parseInt(next()); } public long nextLong() { return Long.parseLong(next()); } public double nextDouble() { return Double.parseDouble(next()); } public String next() { try { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } } catch (Exception e) { e.printStackTrace(); } finally { return st.nextToken(); } } }