結果
問題 | No.939 and or |
ユーザー |
![]() |
提出日時 | 2019-12-04 11:45:05 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 56 ms / 2,000 ms |
コード長 | 1,264 bytes |
コンパイル時間 | 2,225 ms |
コンパイル使用メモリ | 77,612 KB |
実行使用メモリ | 37,352 KB |
最終ジャッジ日時 | 2024-11-30 02:49:40 |
合計ジャッジ時間 | 4,473 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 30 |
ソースコード
package _939; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.regex.Pattern; public class Main { public void solve(BufferedReader stdin, PrintWriter stdout) throws NumberFormatException, IOException { Pattern space = Pattern.compile(" "); String[] line = space.split(stdin.readLine()); long a = Long.parseLong(line[0]); long b = Long.parseLong(line[1]); long n = 0; for (long i = 31; i >= 0; i--) { if ((a & (1 << i)) == 0) { if ((b & (1 << i)) != 0) { n++; } } else { if ((b & (1 << i)) == 0) { stdout.println(0); return ; } } } long ans = 1; for (long i = 0; i < n - 1; i++) ans *= 2; stdout.println(ans); } public static void main(String[] args) throws NumberFormatException, IOException { BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in)); PrintWriter stdout = new PrintWriter(System.out, false); new Main().solve(stdin, stdout); stdout.flush(); } }