\(CF\ EDU\ 83\)
\(C\)
The meaning of problems
Given a length \ (n-\) and the initial value \ (0 \) sequence \ (V \) and a length \ (n-\) sequence \ (A \) .
Given \ (K \) , each operation, or a \ (v [pos] \) is increased \ (STEP K ^ {} \) , or the current operation is skipped, \ (STEP \) from \ (0 \) starts counting, the end of each round \ (step \) increment.
Can you make \ (v \) becomes \ (A \) ?
answer
Consider into \ (k \) hex solved.
For each \ (a [i] \) , which \ (K \) of each of the hexadecimal representation \ (digit for \) must be \ (1 \) , while all of the \ (a [i] \ ) dismantle bit digital number must not be repeated.
\(code\)
int t, n, k;
int b[100];
bool check(LL x)
{
int i = 0;//digit 编号
while(x) {
if(x % k == 1 && b[i]) return 0;
if(x % k > 1) return 0;
if(x % k == 1) b[i] = 1;
x /= k;
i++;
}
return 1;
}
int main()
{
scanf("%d", &t);
while(t--){
memset(b, 0, sizeof(b));
scanf("%d %d", &n, &k);
int f = 0;
LL x;
for(int i = 1; i <= n; ++i){
scanf("%lld", &x);
if(!check(x)) f = 1;
}
if(f) puts("NO");
else puts("YES");
}
return 0;
}