PRIM

Time limit2sMemory limit512 MB

Summary
For each of T test cases, given an array of n integers, replace every element with the smallest prime that is at least that element, then print the sum.
Level

Easy3 of 10

Topics
Number theory, Math, Array, Implementation
Solved
No attempts yet

Problem

Given an array of 5 integers, find for each element the smallest prime number that is not less than that element.

Input

The first line gives the number of test cases, T.

Each test case gives an array of integers I of length n, separated by spaces.

  • 0 < I < 10^6
  • 0 < n < 10^6

Output

For each test case, print the sum of the prime numbers obtained.

Examples1

  1. Example 1

    Input
    2
    1254 12 1859 9762 6
    5 6 8 10 15
    
    Expected output
    12907
    51