結果

問題 No.130 XOR Minimax
ユーザー ふう
提出日時 2015-01-26 17:23:41
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
RE  
実行時間 -
コード長 864 bytes
コンパイル時間 610 ms
コンパイル使用メモリ 82,172 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-23 03:15:31
合計ジャッジ時間 5,365 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other RE * 21
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:63:17: warning: ‘res’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   63 |         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[100];
	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