結果

問題 No.939 and or
コンテスト
ユーザー bal4u
提出日時 2019-12-06 20:07:11
言語 C(gnu17)
(gcc 15.2.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 417 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 120 ms
コンパイル使用メモリ 38,976 KB
最終ジャッジ日時 2026-02-22 04:56:21
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

// yuki 939 and or
// 2019.12.6 bal4u

#include <stdio.h>

typedef long long ll;

int main()
{
	int A, B;
	ll ans;
	
	scanf("%d%d", &A, &B);
	if (A > B) ans = 0;
	else if (A == B) ans = 1;
	else {
		ans = 1;
		while (B) {
			int a = A & 1, b = B & 1;
			if (a && b == 0) { puts("0"); return 0; }
			if (a == 0 && b) ans <<= 1;
			A >>= 1, B >>= 1;
		}
		if (ans > 1) ans >>= 1;
	}
	printf("%lld\n", ans);
	return 0;
}
0