A
思路:a【1】是其他元素的因子,不易证
/**/
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i <= b; i ++)
#define endl '\n'
using namespace std;
const int N = 100 + 5, INF = 1e9 +5;
int a[N];
void s(){
int n ;cin >> n;
for(int i = 1; i <= n; i ++) cin >> a[i];
for(int i = 2; i <= n ;i ++){
if(a[i] % a[1] != 0) {
cout << "NO\n"; return ;
}
}
cout << "YES\n";
}
int main(){
cin.tie(0);cout.tie(0);ios::sync_with_stdio(0);
int t; cin >>t; while(t--) s();
return 0;
}
B
思路:检查l--r之间是否有i的倍数
#include<iostream>
#include<cstring>
using namespace std;
typedef long long LL;
const int maxn = 1e5 + 5, INF = 0x3f3f3f3f;
int ans[maxn];
int main(){
cin.tie(0);
cout.tie(0);
ios::sync_with_stdio(0);
int T;
cin >> T;
while(T--){
int n, l, r;
cin >> n >> l >> r;
bool success = 1;
for(int i = 1; i <= n; i++){
int t = (l + i - 1) / i * i;
if (t > r){
success = 0;
break;
}
ans[i] = t;
}
if (success){
cout << "YES" << '\n';
for(int i = 1; i <= n; i++) cout << ans[i] << " \n"[i == n];
}
else cout << "NO" << '\n';
}
}