結果
問題 | No.939 and or |
ユーザー |
![]() |
提出日時 | 2019-12-03 00:20:33 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 134 ms / 2,000 ms |
コード長 | 488 bytes |
コンパイル時間 | 2,023 ms |
コンパイル使用メモリ | 73,896 KB |
実行使用メモリ | 54,288 KB |
最終ジャッジ日時 | 2024-11-25 02:21:14 |
合計ジャッジ時間 | 7,157 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 30 |
ソースコード
import java.util.Scanner; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); sc.close(); if ((a & b) != a) { System.out.println(0); return; } int c = b - a; int cnt = 0; for (int i = 0; i < 32; i++) { if ((c >> i & 1) == 1) { cnt++; } } if (cnt == 0) { System.out.println(1); } else { System.out.println(1 << (cnt - 1)); } } }