func_code_string: #include <bits/stdc++.h>   using namespace std;   const long long inf = 1e9 + 5;   long long power(long long x, long long y) {     long long res = 1;     while (y > 0) {       if (y & 1) res = res * x;       y = y >> 1;       x = x * x;     }     return res;   }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     ;     long long t;     cin >> t;     while (t--) {       long long n, k;       cin >> n >> k;       long long a[n];       for (long long i = 0; i < n; i++) cin >> a[i];       set<long long> s;       bool f = 1;       if (k == 1) {         cout <<  YES  <<   n ;         continue;       }       for (long long i = 0; i < n; i++) {         if (a[i] == 0) continue;         long long temp = a[i];         while (temp > 0) {           for (long long j = 0; j < 1e5; j++) {             if (temp < power(k, j)) {               temp -= power(k, j - 1);               if (s.count(j - 1)) {                 f = 0;                 break;               } else {                 s.insert(j - 1);               }               break;             }           }         }         if (f == 0 || temp != 0) {           f = 0;           break;         }       }       cout << (f == 0 ?  NO  :  YES ) <<   n ;     }     return 0;   }   