結果

問題 No.939 and or
ユーザー bal4u
提出日時 2019-12-06 20:07:11
言語 C
(gcc 13.3.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 417 bytes
コンパイル時間 112 ms
コンパイル使用メモリ 29,312 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-12-23 16:16:29
合計ジャッジ時間 1,128 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

// 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