結果

問題 No.939 and or
コンテスト
ユーザー bal4u
提出日時 2019-12-06 19:44:11
言語 C(gnu17)
(gcc 15.2.0)
コンパイル:
gcc-15 -O2 -std=gnu17 -Wno-error=implicit-function-declaration -Wno-error=implicit-int -Wno-error=incompatible-pointer-types -Wno-error=int-conversion -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 570 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 331 ms
コンパイル使用メモリ 39,140 KB
最終ジャッジ日時 2026-02-22 04:56:19
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 29 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

// yuki 939 and or
// 2019.12.6 bal4u

#include <stdio.h>

typedef long long ll;

int i2bin(char *a, int n) {
	int w = 0;
	while (n) {
		*a++ = (n & 1), n >>= 1;
		++w;
	}
	return w;
}

int main()
{
	int i, a, b, sa, sb, s;
	ll ans;
	char A[35], B[35];
	
	scanf("%d%d", &a, &b);
	if (a > b) { puts("0"); return 0; }
	sa = i2bin(A, a);
	sb = i2bin(B, b);
	s = sa; if (sb > s) s = sb;
	ans = 1;
	for (i = 0; i < s; ++i) {
		if (A[i] && B[i] == 0) { puts("0");	return 0; }
		if (A[i] == 0 && B[i]) ans <<= 1;
	}
	if (ans > 1) ans >>= 1;
	printf("%lld\n", ans);
	return 0;
}
0