#include<bits/stdc++.h>
using namespace std;
#define maxn 10010
int m1, m2, n, pri[maxn], tot[maxn], a[maxn];
int Decomposition(int x){
int cnt = 0, Cnt=0;
for (int i = 2; i <= x / i; i++)
for (; x % i == 0; x /= i)
a[++cnt] = i;
if (x > 1) a[++cnt] = x;
for (int i = 1; i <= cnt; i++, tot[Cnt]++)
if (a[i] != a[i - 1]) pri[++Cnt] = a[i];
return cnt;
}
int main()
{
scanf("%d%d%d", &n, &m1, &m2);
int cnt = Decomposition(m1), ans = 2e9, s;
while (n--)
{
scanf("%d", &s);
int x = 0;
for (int i = 1; i <= cnt; i++)
{
int p = pri[i];
if (s % p != 0)
{
x = -1;
break;
}
else
{
int e = 0;
for (; s % p == 0, s /= p)
e++;
x = max(x, 1 + (m2 * tot[i] - 1) / e);
}
}
if (x >= 0) ans = min(ans, x);
}
if (ans >= 2e9) puts("-1");
else printf("%d", ans);
return 0;
}
这串代码 《半江绿绿半江紫》