Logo
(追記) (追記ここまで)

19841번 - Prime Suffixes 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 512 MB178533526.515%

문제

Let us call a number $y$ a suffix of a number $x,ドル if we can remove digits from the beginning of a decimal representation of $x$ to get $y$. Note that if there are no zeroes in a decimal representation of $x,ドル all suffixes of $x$ contain no leading zeroes. For example, suffixes of 283ドル$ are 283ドル,ドル 83ドル$ and 3ドル$.

An integer is called prime, if its has exactly two positive integer divisors. The number 1ドル$ is not prime --- it has only one positive integer divisor.

Senya likes prime numbers that have no zeroes in their decimal representation, such that all of their suffixes are also prime.

You are given integers $a$ and $b$. Help Senya to find out, how many integers between $a$ and $b$ are there that he likes.

입력

Input contains two integers $a$ and $b$ (1ドル \le a \le b \le 10^{11}$).

출력

Print the number of primes between $a$ and $b$ inclusive, such that they have no zeroes in their decimal representation, and if any number of their leading digits are removed, the resulting number is still prime.

제한

예제 입력 1

4 13

예제 출력 1

3

예제 입력 2

101 109

예제 출력 2

0

예제 입력 3

281 286

예제 출력 3

1

힌트

In the first example Senya likes integers 5ドル,ドル 7ドル$ and 13ドル$.

In the second example all integers in the range contain 0ドル$ in their decimal respresentation.

In the third example Senya likes integer 283ドル,ドル since 283ドル,ドル 83ドル$ and 3ドル$ are all prime.

출처

Olympiad > Russian Olympiad in Informatics > Russia Team High School Programming Contest > Russia Team High School Programming Contest 2017 L번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /