蒟蒻求神犇指教(必关)
查看原帖
蒟蒻求神犇指教(必关)
1372344
ZJY1207楼主2024/8/26 19:18
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,n;
	cin>>a>>n;
	for(int i=0;i<n;i++){
		int k;
		cin>>k;
		double x;
		x=sqrt(k);
		if(x-int(x)==0&&k>=a){
			cout<<"lucky"<<endl;
		} 
		else{
			bool f1=false;
			for(int j=2;j*j<=k;j++){
				if(k%(j*j)==0&&j*j*(k/j)>=a){
					f1=true;
					break;
				}
			}
			if(f1){
				cout<<"lucky"<<endl;
			}else{
				if(k<a){
					k=a;
				}
				while(true){
					bool y=false;
					x=sqrt(k);
					if(x-int(x)==0){
						cout<<k<<endl;
						break;
					} else{
						for(int j=2;j*j<k;j++){
							if(k%(j*j)==0){
								cout<<k<<endl;
								y=true;
								break;
							}
						}
					}
					if(y){
						break;
					}
					k++;
				}
			}
		}
	}
}
2024/8/26 19:18
加载中...