跳到正文

题解

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

tuantuan8888约 2 分钟
原文
文章信息与版本

文章信息

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

版本

  1. v1当前

对于  mod \bmod 2642^{64},只需要使用 unsigned long long 的自然溢出实现即可。

考虑优化,因为模数不是质数,所以答案很可能会是 00 。

因为只要两数奇偶性相同,就至少生出 11 个 22的质因子 。

所以对于很大的 nn,答案一定是 00 。

暴力枚举,乘完一项后,如果答案变成 00,就输出 00,否则继续,最后输出。

C++
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 2;
const int M = 64;
int n;
unsigned long long a[N];
void solve()
{
	scanf("%d",&n);
	for(int i = 1; i <= n; i++) cin >> a[i];
	sort(a + 1,a + n + 1);
	for(int i = 1; i < n; i++)
		if(a[i] == a[i + 1])
		{
			printf("0\n");
			return;
		}
	unsigned long long total = 1;
	for(int i = 1; i <= n; i++)
		for(int j = 1; j < i; j++)
		{
			total *= (a[i] ^ a[j]);
			if(total == 0) 
			{
				printf("0\n");
				return;
			}
		}
	cout << total << "\n";
}
signed main()
{
	cin.tie(0); cout.tie(0);
	int T; scanf("%d",&T);
	while(T--) solve();
}
原文