题解 | #素数回文#

素数回文

https://ac.nowcoder.com/acm/problem/14703

素数回文

#include <bits/stdc++.h>

using namespace std;

typedef long long LL;

string s;

bool isprime(LL n)
{    
    for(LL i = 2; i <= n / i; i ++)
        if(n % i == 0)
            return false;
    return true;
}

int main()
{
    cin >> s;
    //生成该数的回文数
    for(int i = s.size() - 2; i >= 0; i --)
        s += s[i];
    
    LL t = stoll(s);//string 转 long long
    if(isprime(t)) cout << "prime";
    else cout << "noprime";
    
    return 0;
}
全部评论

相关推荐

2025-12-25 16:26
已编辑
河北科技学院 Java
勇敢的牛油不服输:2800-300那不等于2500一个月吗兄弟们
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务