标签:contest cin ORC ble cpp put c++ problem end
每次不能重复使用k的幂,问能不能构造数组中的每一个数 。
对所有的数进行因式分解,所有数的k进制位上的数不能大于1,大于1就输出NO,否则就输出YES。
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
int t;
cin >> t;
while(t--){
int n,k;
cin >> n >> k;
int a[100]={0};
for(int i = 0; i < n; i++){
ll x;
cin >> x;
int cnt = 0;
while(x){
a[cnt++] += x%k;
x /= k;
}
}
bool flag = 0;
for(int i = 0; i < 100; i++){
if(a[i] > 1){
puts("NO");
flag = 1;
break;
}
}
if(flag==0) cout<<"YES"<<endl;
}
return 0;
}
标签:contest cin ORC ble cpp put c++ problem end
原文地址:https://www.cnblogs.com/AC-AC/p/12457920.html