6.细胞**
2022-12-30 09:26:45
发布于:江苏
481阅读
0回复
0点赞
6.[NOIP2009 普及组] 细胞分裂
难度:普及-
来源:NOIP普及组
AC代码(C++):
#include <bits/stdc++.h>
using namespace std;
int n,m1,m2,ans = 150000;
int i,j;
int s[10001],f[10001];
bool p[30001];
int prime[501][3],size = 0;
int main(void)
{
memset(p,1,sizeof(p));
memset(f,0,sizeof(f));
scanf("%d%d%d",&n,&m1,&m2);
if (m1 == 1)
{
printf("0");
return 0;
} // If the number of tubes is 1, the conditions are met directly 若试管数为1,直接符合条件
for (i = 1; i <= n; i++)
scanf("%d",&s[i]);
int xx = floor(sqrt(m1));
for (i = 2; i <= xx; i++)
{
// Quality finding factor 找质因数
if (p[i])
{
if (m1 % i == 0)
{
prime[++size][1] = i;
prime[size][2] = 1;
}
}
int tim = 2;
while (tim * i <= m1)
{
p[tim * i] = 0;
tim++;
}
}
for (i = 1; i <= size; i++) // Number of quality finding factors 找质因数个数
{
int num = prime[i][1];
while (m1 % (num * prime[i][1]) == 0)
{
num *= prime[i][1];
prime[i][2]++;
}
prime[i][2] *= m2;
}
if (size == 0) // If it is a prime number, the prime factor is itself 若为质数,质因数为本身
{
prime[++size][1] = m1;
prime[size][2] = m2;
}
for (i = 1; i <= n; i++)
{
for (j = 1; j <= size; j++)
{
if (s[i] % prime[j][1] != 0) // If there is no certain factor, break directly
{
f[i] = 150000; // Maximum: 10000 * log 2 30000
break;
}
int tim = 1;
long long num = prime[j][1];
while (s[i] % (num * prime[j][1]) == 0)
{
num *= prime[j][1];
tim++;
}
int an = (prime[j][2]-1) / tim + 1; // Equivalent to ceil function
if (an > f[i]) f[i] = an;
}
}
for (i = 1; i <= n; i++)
if (ans > f[i]) ans=f[i];
if (ans == 150000) printf("-1");
else printf("%d",ans);
return 0;
}
此处英文注释为自己靠着自己的英语知识使用百度翻译(fanyi.baidu.com/#zh/en/)所写,请酌情添加
全部评论 2
这英文的文风感觉好像chatgpt...
2024-10-19 来自 江苏
0不是这“分裂”也能变“**”?
2022-11-24 来自 江苏
0ME too.
2023-01-14 来自 重庆
0根本就没打卡机灌灌灌灌嘎嘎嘎嘎嘎嘎不拿个发v更好反反复复凤飞飞发发发发发发发发发发发发发发发发发发发发发发那那那那那那那那那那vvvvvvvvvVB叭叭叭巴巴爸爸巴巴爸爸巴巴爸爸巴巴爸爸巴巴爸爸巴巴爸爸巴巴爸爸巴巴爸爸巴巴爸爸巴巴爸爸巴巴爸爸斤斤计较急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急热热热柔柔弱弱柔柔弱弱然然然然然然然然然然
2023-04-16 来自 江苏
0?
2024-05-07 来自 江苏
0
有帮助,赞一个