编程介的小学生 2019-05-18 19:09 采纳率: 20.5%
浏览 237

回文的数字的一个判定程序的编写,怎么利用C语言的代码编程的思想的实现的方法?

Problem Description
Prime numbers are defined as follows: a number is prime if it is greater than 1 and is evenly divisible only by itself and 1. Note that by definition neither zero nor one is a prime number.
A palindromic number is one whose string representation is a palindrome, that is, a string that reads the same backwards and forwards.
You are on the clue crew preparing questions for the category “Palindromic Primes” and are to write a program to generate the answer and responding question in Jeopardy! style.

Input
The input file contains a series of number pairs (with white space separating them) specifying individual problems, ending with a pair of zeroes. The first number gives the number of digits for the numbers to be considered, the second number gives the base in which the numbers are to be generated. The numbers are separated by a single space. You are assured that all palindromic primes for this problem can be represented in the range of a standard 32-bit signed integer. The bases allowed are integer bases between 2 and 36 — with bases above base ten handled as extensions of hexadecimal. This means that the valid numeric digits are in the range [‘0’..‘9’] and [‘a’..‘z’].

Output
For each number, generate one line giving the number of digits and the base as the answer and then on the next line the number of palindromic primes found as the question as shown in the sample output. Each output pair should be separated by a blank line.

Sample Input
1 10
2 10
3 10
4 24
5 4
0 0

Sample Output
The number of 1-digit palindromic primes < 2^31 in base 10.
What is 4?

The number of 2-digit palindromic primes < 2^31 in base 10.
What is 1?

The number of 3-digit palindromic primes < 2^31 in base 10.
What is 15?

The number of 4-digit palindromic primes < 2^31 in base 24.
What is 0?

The number of 5-digit palindromic primes < 2^31 in base 4.
What is 10?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥50 易语言把MYSQL数据库中的数据添加至组合框
    • ¥20 求数据集和代码#有偿答复
    • ¥15 关于下拉菜单选项关联的问题
    • ¥20 java-OJ-健康体检
    • ¥15 rs485的上拉下拉,不会对a-b<-200mv有影响吗,就是接受时,对判断逻辑0有影响吗
    • ¥15 使用phpstudy在云服务器上搭建个人网站
    • ¥15 应该如何判断含间隙的曲柄摇杆机构,轴与轴承是否发生了碰撞?
    • ¥15 vue3+express部署到nginx
    • ¥20 搭建pt1000三线制高精度测温电路
    • ¥15 使用Jdk8自带的算法,和Jdk11自带的加密结果会一样吗,不一样的话有什么解决方案,Jdk不能升级的情况