T342048 [梦熊-六月-T3] 台式烤香肠WA#5,6,7,8,9,10
查看原帖
T342048 [梦熊-六月-T3] 台式烤香肠WA#5,6,7,8,9,10
661913
liwenxi1145144444楼主2023/6/23 17:09
#include<bits/stdc++.h>
using namespace std;
long long l,r;
long long a[1000005],ans=1;
bool judge(long long x){
	if(x<2){
		return 0;
	}
	for(long long i=2;i*i<=x;i++){
		if(x%i==0){
			return 0;
		}
	}
	return 1;
}
int main(){
	cin>>l>>r;
	for(long long i=1;i;i++){
		if(i*i>1000000000000ll){
			break; 
		}
		a[i]=i*i;
	}
	bool vis=0;
	for(long long i=1;i<=1000000;i++){
		if(a[i]>=l&&a[i]<=r){
			long long sum=0,x=a[i];
			while(x){
				sum+=x%10;
				x/=10;
			}
			if(judge(sum)){
				ans=(ans*a[i]%998244353ll);
				vis=1;
			}
		}
		if(a[i]>r){
			break;
		}
	}
	if(vis==0){
		cout<<0;
	}else{
		cout<<ans%998244353ll;
	}
	return 0;
}
2023/6/23 17:09
加载中...