CodeForces 171F (qiangu Shen question ..)

Source: Internet
Author: User

CodeForces 171F (qiangu Shen question ..)
Mongomongod-joyTime Limit:2000 MSMemory Limit:65536KB64bit IO Format:% I64d & % I64uSubmit Status Practice CodeForces 171F

Description

Qd ucyhf yi q fhycu dkcruh mxeiu huluhiu yi q tyvvuhudj fhycu dkcruh. oekh jqia yi je vydt jxu djx ucyhf.

Input

Jxu ydfkj sediyiji ev q iydwbu ydjuwuhD(1? ≤?D? ≤? (11184)-jxu edu-rqiut ydtun ev jxu ucyhf je vydt.

Output

Ekjfkj q iydwbu dkcruh.

Sample Input

Input
1
Output
13


God question ..

Is it hard to understand the question...

Is there a problem with the question ..

In fact, the question itself is a password ..

The password rule is (letter + 10 ).

If q is 17th letters, it should be reduced by 16 to.

OK, so first write a program and understand the question first.

As follows:



Question:

Ask you to calculate the nth antiprime number. (N is at most 11184)

Inverse prime number (after inversion, it is still a prime number, and it is not equal to the original number ).

For example, 13 is used to reverse 31 or a prime number.

13 is the first antiprime number.

Solution:

First, create a table to determine the number of anti-prime numbers.

Then, the system will not time out when the loop is larger than it.

The maximum inverse prime number in the specified range is 999983.

Open the array to 1 million.

Code:

# Include
 
  
# Include
  
   
# Include using namespace std ;__ int64 prime [10000] ;__ int64 a [1222222] ;__ int64 sushu (_ int64 a) {__ int64 I; __int64 k = sqrt (a); for (I = 2; I <= k; I ++) {if (a % I = 0) return 0 ;} return 1; // determine the prime number }__ int64 rev (_ int64 sum) {__ int64 now = 0; while (sum) {now * = 10; now + = sum % 10; sum/= 10;} return now; // reverse} int main () {__ int64 I, j ;__ int64 n ;__ int64 l, l1; l = 0; l1 = 1;/* for (I = 1; I <1020022; I ++) {if (sushu (I )) {prime [l ++] = I; printf ("% I64d \ n ", I) ;}} * // comments for (I = 0; I <1000000; I ++) {if (I! = Rev (I) & sushu (I) {a [l1 ++] = I; // printf ("% d \ n", I) ;}} while (scanf ("% I64d", & n )! = EOF) {printf ("% I64d \ n", a [n]);} return 0 ;}
  
 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.