結果

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

ソースコード

diff #

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