1144:素数回文
来源:互联网 发布:php去掉空格 编辑:程序博客网 时间:2024/05/21 02:51
1144:素数回文
Description
小王对既是素数又是回文的数特别感兴趣。比如说151既是素数又是个回文。现在小王想要你帮助他找出某个范围内的素数回文数,请你写个程序找出 a 跟b 之间满足条件的数。(5 <= a < b <= 100,000,000);
Input
输入a和b(5 <= a < b <= 100,000,000)
Output
按从小到大输出a,b之间所有满足条件的素数回文数
Sample Input
5 500
Sample Output
5711101131151181191313353373383
#include<iostream>using namespace std;int main(){ int a,b,i; cin>>a>>b; for(i=a;i<=b;i++) { int count=0,temp,j; for(j=2;j<i;j++) { if(i%j==0) break; } if(j==i) { temp=i; while(temp!=0) { count=count*10+temp%10; temp=temp/10; } } if(count==i) cout<<i<<endl; } return 0;}
阅读全文
0 0
- 1144: 素数回文
- 1144:素数回文
- 素数回文
- 回文素数
- 回文素数
- 回文素数
- 回文素数
- 回文素数
- 【素数回文】
- 回文素数
- 素数回文
- 回文素数
- 回文素数
- 回文素数
- 回文素数
- 回文素数
- 回文素数
- 回文素数
- weblogic 访问返回401-Unauthorized
- HDU 5862 Counting Intersections(树状数组)
- "没有废物"之前世今生(续)
- 经验分享 | 10 个最基本的JS面试问题及答案
- [RK3288][Android6.0] 调试笔记 --- CPU温度降频控制
- 1144:素数回文
- React native 上传图片遇到的问题
- TCP连接的状态详解以及故障排查
- web.xml里的Servlet和Filter示例
- 第一篇
- tarjan求强连通分量
- Java语言基础小结5
- std::lock_guard 和 std::unique_lock的区别
- Python笔记--函数式编程