Compare commits

...

2 Commits

Author SHA1 Message Date
黄海 5a2aa2ca5a 'commit'
1 year ago
黄海 5cb78faacc 'commit'
1 year ago

@ -0,0 +1,51 @@
#include <bits/stdc++.h>
using namespace std;
const int N = 10010;
int T;
int a[N];
int n;
/*
2
3
1 2 4
5
1 2 3 4 5
*/
bool check() {
//遍历a[1]~a[n]中每个数字
// 当前枚举到的数字是a[i]
// 判断当前数字a[i]是不是其它数的倍数,不需要避开自己,因为自己肯定是自己的倍数
// 找完一圈后发现a[i]是其它数字的倍数返回true
// 找完一圈后发现a[i]不是其它数字的倍数则i++
//如果到了最后一个还没有找到是其它数倍数的数字那么返回false
for (int i = 1; i <= n; i++) {
bool flag = false;//默认a[i]是好用的
for (int j = 1; j <= n; j++) {
if (a[i] % a[j]) { //a[i]不是a[j]的倍数,么a[i]是个废物,后续的a[j]不用继续讨论了
flag = true;//用来标记是中间被打断的也就是不合理的a[i]
break;
}
}
//到达了这里
if (!flag)
return true;
}
return false;
}
int main() {
cin >> T;
while (T--) {
cin >> n;
for (int i = 1; i <= n; i++)
cin >> a[i];
if (check())
cout << "YES" << endl;
else
cout << "NO" << endl;
}
return 0;
}

@ -0,0 +1,7 @@
#include <bits/stdc++.h>
using namespace std;
int main() {
return 0;
}
Loading…
Cancel
Save