跳到正文

题解

题解:P13683 【MX-X16-T1】「DLESS-3」XOR and Greater Sum

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

文章信息

收录
2025年12月12日
更新
2026年10月23日
篇幅
约 1 分钟
题目
P13683

版本

  1. v1当前

洛谷 P13683

题目大意:

给定 tt 组数据,每一个数据包含一个 nn,接下来有 nn 个数,分别为每一个 aia_i。对于每一组数据,如果可以通过选一些数异或和大于剩下的数的异或和,就输出 Yes,否则输出 No。

解题思路:

这道题很简单,只用判断全选后,异或和是否为 00。因为如果全选还不满足,不全选更不能满足。如果全选后异或和确实不为零,输出 Yes,否则输出 No。

AC 代码:

C++
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N = 1e6+20;
int t, n;
int a[N];
signed main() {
	cin >> t;

	while (t--) {
		cin >> n;
		int sum = 0;

		for (int i = 1; i <= n; i++) {
			cin >> a[i];
			sum ^= a[i];
		}

		if (sum == 0) {
			cout << "No" << endl;
		} else {
			cout << "Yes" << endl;
		}
	}

	return 0;
}
原文