玄二关求助,80pts,WA on #4, #9
查看原帖
玄二关求助,80pts,WA on #4, #9
782768
Mierstan085楼主2024/10/25 16:42

rt,代码如下,麻风良好,但是乱:

#include <bits/stdc++.h>
#define int long long
using namespace std;

int cnc(int x){
    int ret = 0;
    while (x){
        ret += x % 10;
        x /= 10;
    }
    return ret;
}

bool isp(int x){
    if (x % 2 == 0 || x == 1) return 0;
    for (int i = 3; i * i <= x; i += 2){
        if (x % i == 0) return 0;
    }
    return 1;
}

signed main(){
    long long l, r;
    cin >> l >> r;
    //cout << sqrt(l) << ' ' << sqrt(r) << endl;
    
    long long cntt = 1, cnt; bool flag = 0;
    for (long long i = floor(sqrt(l)); i * i <= r; i ++){
        //cout << i << ' ' << i * i << ' ' << cnc(i * i);
        if (isp(cnc(i * i))){
        //    cout << " YES!";
            cnt = i % 998244353ll;
            cntt %= 998244353ll;
            cntt *= (cnt * cnt) % 998244353ll;
            cntt %= 998244353ll;
            flag = 1;
        }
        //cout << cntt << endl;
    }
    
    if (!flag) cout << 0;
    else cout << cntt;
}
2024/10/25 16:42
加载中...