結果

問題 No.939 and or
ユーザー bal4ubal4u
提出日時 2019-12-06 19:44:11
言語 C
(gcc 12.3.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 570 bytes
コンパイル時間 316 ms
コンパイル使用メモリ 29,148 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-25 03:21:56
合計ジャッジ時間 2,008 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 WA -
testcase_03 AC 0 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 0 ms
4,384 KB
testcase_11 WA -
testcase_12 AC 0 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 1 ms
4,376 KB
testcase_17 WA -
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 WA -
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 WA -
testcase_25 AC 1 ms
4,380 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 0 ms
4,380 KB
testcase_29 AC 1 ms
4,380 KB
testcase_30 AC 1 ms
4,376 KB
testcase_31 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

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