CE???
查看原帖
CE???
1020370
ztt0430楼主2024/6/16 23:24

为什么编译错误???

#include<bits/stdc++.h>
#define int long long
using namespace std;
int n;
int m1,m2;
int prime[300005],cnt;
int pipe[300005],cnt1=1;
int cell[300005],cnt2=1,cells;
bool flag,flagans;
int ans=0x3f3f3f,now;
bool rp(int x){
	for(int j=2;j*j<=x;j++)if(x%j==0)return 0;
	return 1;
}
signed main(){
	cin>>n>>m1>>m2;
	for(int i=2;i<=30000;i++)if(rp(i))prime[++cnt]=i;
	while(m1!=1){
		while(m1%prime[cnt1]==0){
			pipe[cnt1]+=m2;
			m1/=prime[cnt1];
		}
		cnt1++;
	}
	for(int i=1;i<=n;i++){
		cin>>cells;
		flag=1;now=0x3f3f3f;cnt2=1;
		memset(cell,0,sizeof(cell));
		while(cells!=1){
			while(cells%prime[cnt2]==0){
				cell[cnt2]++;
				cells/=prime[cnt2];
			}
			cnt2++;
		}
		for(int j=1;j<=cnt;j++)
			if(pipe[j]&&!cell[j]){flag=0;break;}
			else if(pipe[j]&&cell[j]){
				if (pipe[j] % cell[j])
				now=min(now, pipe[j] / cell[j] +1 );	
				else now=min(now, pipe[j] / cell[j] +1 );	
			}
		if(flag){flagans=1,ans=min(ans,now);}
	}
	if(flagans)
	cout<<ans;
	else cout<<"-1";
}
2024/6/16 23:24
加载中...