fork download
  1. #include <bits/stdc++.h>
  2. #define ll long long
  3. #define ld long double
  4. #define vc vector
  5. #define yes cout << "YES" << '\n'
  6. #define no cout << "NO" << '\n'
  7. #define el '\n'
  8. #define ln cout << '\n'
  9. #define pb push_back
  10. #define all(x) (x).begin(),(x).end()
  11. #define alli(n) int i = 0 ; i< n ;i++
  12. #define cin(v) for(auto& ele : v)cin>>ele
  13. #define print(v) for(auto& ele : v)cout << ele << ' '
  14. #define test1(x) cout << x << '\n'
  15. #define test(x,y) cout << x << ' ' << y << '\n'
  16. #define var int n;cin>>n
  17. #define var1 int n,m;cin>>n>>m
  18. #define vc2Dint vector<vector<int>>
  19. #define vc2Dll vector<vector<long long>>
  20. #define cin2D(v) for(auto& row : (v))for(auto& col : row)cin>>col
  21. #define print2D(v) for(auto& row : v){for(auto& col: row)cout << col << ' ';ln;}
  22.  
  23. using namespace std;
  24. ll mod = 1e15 , oo = 1e18;
  25.  
  26.  
  27. bool getBit(int x,int idx){ return x&(1<<idx);}
  28. int setBit1(int x,int idx){return x|(1<<idx);}
  29. int setBit0(int x,int idx){ return x&~(1<<idx);}
  30. int toggleBit(int x,int idx){return x^(1<<idx);}
  31. int cntBit(int x){int cnt=0;while(x){if(x%2)cnt++;x/=2;}return cnt;}
  32. // ================================== bitmask built in functions ==================================
  33. // __builtin_popcount(unsigned int)returns the number of set bits
  34. // __builtin_ffs(int) finds the index of the first (most right) set bit
  35. // __builtin_ctz(unsigned int) the count of trailing zeros(right zeros)
  36.  
  37. // ================================== math theory functions ==================================
  38. vc<ll> getDivisors(ll n){vc<ll> v;ll i = 1;for( ; i*i < n ; i++){if(n%i == 0){v.pb(i);v.pb(n/i);}}if(i*i == n)v.pb(i);return v;}
  39.  
  40. vc<bool> sieve(ll n){vc<bool> is_prime(n+1, true);is_prime[0] = is_prime[1] = false;for (int i = 2; i * i <= n; i++)
  41. {if (is_prime[i]) {for (int j = i * i; j <= n; j += i)is_prime[j] = false;}}}
  42.  
  43. bool isPrime(ll number) {if (number < 2) {return false;}if (number == 2 || number == 3 || number == 5) {return true;}
  44. if (number % 2 == 0 || number % 3 == 0 || number % 5 == 0) {return false;}
  45. for (ll i = 5; i*i<= number; i += 6) {if (number % i == 0 || number % (i + 2) == 0) {return false;}}return true;}
  46. ll add(ll a,ll b,ll m){return ((a%m)+(b%m))%m;}
  47. ll mul(ll a,ll b,ll m){return ((a%m)*(b%m))%m;}
  48. ll sub(ll a,ll b,ll m){return ((a%m)-(b%m)+m)%m;}
  49. ll gcd(ll a, ll b){ return b == 0 ? a : gcd(b, a % b);}
  50. ll lcm(ll a, ll b){return (a / gcd(a, b)) * b;}
  51. ll factorial(ll n){if(n == 0)return 1;ll i = n , fact = 1;while(n/i != n){fact = mul(fact,i,998244353);i--;}return fact;}
  52. ll npr(ll n , ll r){return factorial(n)/factorial(n-r);}
  53. ll ncr(ll n, ll r){return npr(n,r)/factorial(r);}
  54.  
  55. // ================================== random functions ==================================
  56. void srour(){ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);}
  57. void openFile(){freopen("text.in", "r", stdin);freopen("text.out", "w", stdout);}
  58. ll power(ll x, ll y){ll res = 1;while (y > 0){if (y % 2 == 1)res = mul(res,x,mod);y=y>>1;x = mul(x,x,mod);}return res;}
  59. bool isDivisibleByPowerOf2(int n, int k) {return (n & (1<<k - 1)) == 0;}
  60. bool isPowerOfTwo(unsigned int n) {return n && !(n & (n - 1));}
  61.  
  62. /*
  63.  
  64.   ███████╗██████╗ ██████╗ ██╗ ██╗██████╗
  65.   ██╔════╝██╔══██╗██╔═══██╗██║ ██║██╔══██╗
  66.   ███████╗██████╔╝██║ ██║██║ ██║██████╔╝
  67.   ╚════██║██╔══██╗██║ ██║██║ ██║██╔══██╗
  68.   ███████║██║ ██║╚██████╔╝╚██████╔╝██║ ██║
  69.   ╚══════╝╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝
  70.  
  71.  
  72. ================================================== start of code ==================================================
  73.  
  74. 1 12
  75. 1000000000000
  76.  
  77.  */
  78.  
  79. void solve(){
  80.  
  81. int n,k;cin>>n>>k;
  82. vc<float> v(n);cin(v);
  83.  
  84. float product = 1;
  85. for(alli(n)){
  86. product *= v[i];
  87. }
  88.  
  89. ll l = 1 , r = product;
  90. while(l <= r){
  91. float mid = l+(r-l)/2;
  92. // test(float(float(k)*log10(i)),float(log10(product)));
  93. if(float(float(k)*log10(mid)) == float(log10(product))){
  94. yes;return;
  95. }else if(float(float(k)*log10(mid)) < float(log10(product))){
  96. l = mid+1;
  97. }else{
  98. r = mid-1;
  99. }
  100. }
  101.  
  102. no;
  103.  
  104. }
  105.  
  106.  
  107.  
  108. int main(){
  109. srour();
  110. int t = 1;
  111. // cin>>t;
  112. while(t--)
  113. solve();
  114. return 0;
  115. }
Success #stdin #stdout 0s 5284KB
stdin
 4 4
 2 6 12 9
stdout
YES