跳到正文

个人记录

dfhbt

Gua20131127约 1 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2026年4月27日
篇幅
约 1 分钟

版本

  1. v1当前
C++
#include<bits/stdc++.h>
using namespace std;
#define int long long
bool is(int x){
	if(x == 1 || x == 0){
		return false;
	}
	for(int i = 2;i <= sqrt(x);i ++){
		if(x % i == 0){
			return false;
		}
	}
	return true;
}

signed main(){
	long long l , r , ans = 0;
	cin >> l >> r;
	for(int i = sqrt(l);i <= sqrt(r);i ++){
		if(i * i * 1LL < l){
			continue;
		}
		string s = to_string(i * i * 1LL);
        int val = 0;
        for(int j = 0;j < s.size();j ++){
            val += s[j] - '0';
        }
        if(is(val)){
            if(ans == 0){
                ans = (i * i * 1LL) % 998244353;
            }else{
                ans = ans * (i * i % 998244353) % 998244353;
            }
        }
	}
	cout << ans;
	return 0;
}
原文