F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Palindromic Primes Category in Jeopardy!

Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 348    Accepted Submission(s): 43


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?
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-04-27 07:16:54, Gzip enabled