#include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); long long n,m,p; cin >> n >> m >> p; vector a(n); vector cost(n); vector mul(n); long long amax,rmax; amax = 1; rmax = 1; for (int i=0;i> a[i]; long long tmp = a[i]; amax = max(amax,tmp); while (tmp%p == 0) { tmp /= p; cost[i]++; } mul[i] = tmp; rmax = max(rmax,mul[i]); } vector coss(32,0); for (int i=0;i dp(1024,0); dp[0] = 1; for (int i=0;i<1024;i++) { if (i == 1023) { cout << -1 << endl; break; } if (dp[i]*amax > m) { cout << i+1 << endl; break; } for (int j=1;j<32;j++) { if (i+j >= 1024) break; dp[i+j] = max(dp[i+j],dp[i]*coss[j]); } } }