結果

問題 No.130 XOR Minimax
ユーザー ふうふう
提出日時 2015-01-26 17:24:58
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 867 bytes
コンパイル時間 857 ms
コンパイル使用メモリ 83,364 KB
実行使用メモリ 5,316 KB
最終ジャッジ日時 2023-09-05 06:59:16
合計ジャッジ時間 2,154 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 15 ms
4,376 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:63:10: warning: ‘res’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  cout << res << endl;
          ^~~

ソースコード

diff #

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <map>
#include <list>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <iomanip>

using namespace std;


int nbit(int b, int n)
{

	for (int i = 1; i < n; i++) {
		b /= 2;
	}
	return (b % 2);
}

int get_bitlen(int b)
{
	return ((int)(log(b) / log(2) + 1));
}

int main(void)
{
	int n;
	int a[100000];
	int ma = 0;
	int res;

	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> a[i];
		ma = max(ma, a[i]);
	}

	if(get_bitlen(ma) == 1) {
		res = 0;
		goto next;
	}

	for (int i = get_bitlen(ma); i >= 1; i--) {
		for (int j = 0; j < n; j++) {
			if (nbit(a[j], i) == 0) {
				res = (int)pow(2, i - 1);
				goto next;
			}
		}
	}
	next:


	cout << res << endl;

	return (0);
}
0