题解(A6.细胞分裂)
2024-09-06 14:08:19
发布于:四川
7阅读
0回复
0点赞
#include <iostream>
#include <cstdio>
#include <memory.h>
#define int long long
using namespace std;
int a[100005], b[100005];
signed main(){
int n, m, k, tmp;
cin >> n >> m >> k;
for(int i = 2; i * i <= m; i++){
while(m % i == 0) a[i] += k, m /= i;
}a[m] += k;
int mn = 0x3f3f3f3f;
for(int i = 1; i <= n; i++){
memset(b, 0, sizeof(b));
int mx = 0;
cin >> tmp;
for(int j = 2; j * j <= tmp; j++){
while(tmp % j == 0) b[j], tmp /= j;
}if(tmp > 100000) continue;
b[tmp];
for(int j = 2; j <= 100000; j++){
if(!a[j]) continue;
if(!b[j]) goto test;
mx = max(mx, a[j] / b[j] + bool(a[j] % b[j]));
}
if(1 + 1 == 3){
test: continue;
}
mn = min(mn, mx);
}
cout << (mn == 0x3f3f3f3f ? -1 : mn);
return 0;
}
这里空空如也
有帮助,赞一个