跳到正文

题解

题解:P13685 【MX-X16-T3】「DLESS-3」XOR and Impossible Problem

RN_GH约 1 分钟
原文
文章信息与版本

文章信息

发布
2025年8月11日
收录
2026年6月6日
更新
2026年10月25日
篇幅
约 1 分钟
题目
P13685

版本

  1. v1当前

其实这题也不是很难,我们充分发扬人类智慧,直接暴力过,求管理员大大让我水过题解!!!

上代码!!!

注意事项:要用 unsigned long long !!!

C++
#include <bits/stdc++.h>
using namespace std;
int main() {
	int t;
	cin >> t;
	while (t--) {
		int n;
		cin >> n;
		vector<unsigned long> a(n);
		for (int i = 0; i < n; i++) {
			cin >> a[i];
		}
		unsigned long long ans = 1;
		bool f = true; //判断是否不是0
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				ans *= (a[i] ^ a[j]);
				if (!ans){//如果为0直接结束
					f = false;
					break;
				}
			}
			if (!f){
				break;
			}
		}
		cout << ans << endl;
	}
	return 0;
}
原文