• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
fc2110rxr
博客园    首页    新随笔    联系   管理    订阅  订阅

洛谷P1217 [USACO1.5]回文质数 Prime Palindromes

质数、回文数判断
#include<bits/stdc++.h>
using namespace std;
int a,b;
bool zs(int x)
{
    if(x%2>0)
    {
        for(int i=3;i<x;i+=2)
            if(x%i==0)
                return false;
        return true;
    }else
        return false;
}
bool hws(int x)
{
    int xx=x;
    int y=0;
    while(xx)
    {
        y=y*10+xx%10;
        xx/=10;
    }
}
int main()
{
    cin>>a>>b;
    for(int i=a;i<=b;i++)
    {
        if(hws(i) && zs(i))
            cout<<i<<endl;
    }
    
    return 0;
 } 

 

posted @ 2023-04-02 09:33  em_pty  阅读(20)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3