Make Equal With Mod
题目要求我们进行多次操作,每次任选x(x>=2),\(a_i\)->\(a_i\)%x,使得每个数都相同
当数组中没有1时,我们可以通过有限次操作将数组全部变为0,(0%x=0)
当数组中有1时(x>=2,所以除数无法取1),当数组有一对连续的数时(如1和2),我们取任何数都无法让其相同
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <vector>
using namespace std;
const int N = 2e5 + 10;
const int mod = 1e9 + 7;
#define inf 0x3f3f3f3f
#define endl '\n'
#define x first
#define y second
typedef pair<int, int> PII;
typedef long long ll;
typedef unsigned long long ull;
int a[N];
void solve() {
int n, m;
bool flag = 0;
cin >> n;
for (int i = 0; i < n; i++) cin >> a[i];
for (int i = 0; i < n; i++) {
if (a[i] == 1) {
flag = 1;
break;
}
}
sort(a, a + n);
if (flag) {
for (int i = 0; i < n - 1; i++) {
if (a[i + 1] - a[i] == 1) {
cout << "NO\n";
return;
}
}
cout << "YES\n";
} else
cout << "YES\n";
}
int main() {
int t = 1;
cin.tie(0)->sync_with_stdio(0);
cin >> t;
while (t--) solve();
return 0;
}

浙公网安备 33010602011771号