2267. Prime

单点时限: 5.0 sec

内存限制: 256 MB

Peter is pretty good in dealing with numbers, especially primes. Naturally, that makes him very popular.You want to be popular too, so you’d like to gather some knowledge about prime numbers of your own. You think that prime numbers can be expressed in terms of sequences of consecutive, smaller prime numbers. As it might turn out to be entertaining, you set out to find some.

Given numbers ni; 1<=i <=m, find the smallest prime number that can be expressed as a sum of ni consecutive prime numbers for all i { [1,…,m].

输入格式

The first line contains the number of scenarios.

Every scenario consists of a single line containing the number 1 <= m <= 10, followed by a line containing the numbers ni; 1 <= i <= m separated by spaces.

  • The number m of nis (1<=m<=10).

  • The numbers ni (1 <=ni <=10^4).

  • The result will always be less than 10^7.

输出格式

The output for every scenario begins with a line containing “Scenario #i:”, where i is the number of the scenario counting from 1.

Then print a single line containing the smallest prime number that is a sum of ni consecutive prime numbers for all ni. The result is guaranteed to be less than 10^7. Every scenario is finished by a blank line.

样例

Input
2
2
3 5
3
3 5 7
Output
Scenario 1:
83
Scenario 2:
311
In the example, 83 is the smallest prime that can be expressed as a sum of three and a sum of five consecutive prime numbers (83 = 23 + 29 + 31 = 11 + 13 + 17 + 19 + 23).

3 人解决,13 人已尝试。

5 份提交通过,共有 46 份提交。

9.2 EMB 奖励。

创建: 15 年,8 月前.

修改: 6 年,8 月前.

最后提交: 9 年,12 月前.

来源: TUD Programming Contest 2008 (Training Session), Darmstadt, Germ

题目标签