Page not loading? Try clicking here.
Placeholder

#1740

Prime number 2 1s 64MB

Problems

Given two natural numbers 𝑀 and 𝑁, write a program to find all prime numbers between 𝑀 and 𝑁 inclusive, and then compute their sum and their minimum value.

For example, if 𝑀=60 and N=100, the prime numbers between 60 and 100 inclusive are: 61, 67, 71, 73, 79, 83, 89, 97.

There are 8 primes, their sum is 620, and the minimum is 61.


Input

The first line contains the integer M.

The second line contains the integer N.

  • 1 \le M \le N \le 10,000

  • Both M and N are natural numbers.


Output

If there are prime numbers between M and N, print two lines:

  1. The sum of all primes in the range.

  2. The smallest prime in the range.

If there are no primes in the range, print -1 on the first line.


Example

60

100
620

61


Source

KOI λ³Έμ„  2006 쀑1

You must sign in to write code.