-->
当前位置:首页 > 题库

PROGRAMMING:Prime distance problem

Luz5年前 (2021-05-10)题库460
###Task description
```
Now give you some numbers, ask you to write a program, output these integers adjacent to the nearest prime number, and output its distance length. If there are prime numbers with equal distance length on the left and right, the value on the left and the corresponding distance are output.
If the input integer itself is a prime, then the output of the prime itself, distance output 0
```
###Input format:
```
The first line gives the number of test data groups n (0 < n < = 10000)
In the next n rows, each row has an integer m (0 < m < 1000000),
```
###Output format:
```
Each line outputs two integers a and B
Where a is the prime number nearest to the corresponding test data, and B is the distance between them.
```
###Input example:
```in
three
six
eight
ten
```
###Output example:
```out
5 1
7 1
11 1
```
###Title Source
This topic is selected from nyoj website, online address: http://nyoj.top/problem/24







answer:If there is no answer, please comment