Bamboo Pole-vault is a massively popular sport in Xzhiland. And Master Phi-shoe is a very popular coach for his success. He needs some bamboos for his students, so he asked his assistant Bi-Shoe to go to the market and buy them. Plenty of Bamboos of all possible integer lengths (yes!) are available in the market. According to Xzhila tradition,

Score of a bamboo = Φ (bamboo's length)

(Xzhilans are really fond of number theory). For your information, Φ (n) = numbers less than n which are relatively prime (having no common divisor other than 1) to n. So, score of a bamboo of length 9 is 6 as 1, 2, 4, 5, 7, 8 are relatively prime to 9.

The assistant Bi-shoe has to buy one bamboo for each student. As a twist, each pole-vault student of Phi-shoe has a lucky number. Bi-shoe wants to buy bamboos such that each of them gets a bamboo with a score greater than or equal to his/her lucky number. Bi-shoe wants to minimize the total amount of money spent for buying the bamboos. One unit of bamboo costs 1 Xukha. Help him.

Input

Input starts with an integer T (≤ 100), denoting the number of test cases.

Each case starts with a line containing an integer n (1 ≤ n ≤ 10000) denoting the number of students of Phi-shoe. The next line contains n space separated integers denoting the lucky numbers for the students. Each lucky number will lie in the range [1, 106].

Output

For each case, print the case number and the minimum possible money spent for buying the bamboos. See the samples for details.

Sample Input

3

5

1 2 3 4 5

6

10 11 12 13 14 15

2

1 1

Sample Output

Case 1: 22 Xukha

Case 2: 88 Xukha

Case 3: 4 Xukha

Hint

#include<iostream>
#include<cstdio>
#include<cstring>
#include<sstream>
#include<algorithm>
#include<queue>
#include<vector>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<fstream>
#include<memory>
#include<list>
#include<string>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MAXN 1000030
#define N 10009
#define INF 1000000009
/*
欧拉函数
打表
*/
LL T, n, a[N];
bool notprime[MAXN];
vector<LL> prime;
void Init()
{
memset(notprime, sizeof(notprime), false);
notprime[] = true;
//prime.resize(N);
for (LL i = ; i < MAXN; i++)
{
if (!notprime[i])
{
prime.push_back(i);
for (int j = i + i; j < MAXN; j+=i)
{
notprime[j] = true;
}
}
}
}
LL solve(LL x)
{
return *upper_bound(prime.begin(), prime.end(), x);
}
int main()
{
Init();
scanf("%lld", &T);
for(LL cas = ;cas<=T;cas++)
{
scanf("%lld", &n);
LL sum = ;
for (LL i = ; i < n; i++)
{
scanf("%lld", &a[i]);
sum += solve(a[i]);
}
printf("Case %lld: %lld Xukha\n",cas,sum);
}
return ;
}

Bi-shoe and Phi-shoe 欧拉函数 素数的更多相关文章

  1. Poj 2478-Farey Sequence 欧拉函数,素数,线性筛

    Farey Sequence Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 14291   Accepted: 5647 D ...

  2. lightoj1370欧拉函数/素数筛

    这题有两种解法,1是根据欧拉函数性质:素数的欧拉函数值=素数-1(可根据欧拉定义看出)欧拉函数定义:小于x且与x互质的数的个数 #include<map> #include<set& ...

  3. poj 2480 Longge's problem 欧拉函数+素数打表

    Longge's problem   Description Longge is good at mathematics and he likes to think about hard mathem ...

  4. FZU 1759 欧拉函数 降幂公式

    Description   Given A,B,C, You should quickly calculate the result of A^B mod C. (1<=A,C<=1000 ...

  5. poj3696 快速幂的优化+欧拉函数+gcd的优化+互质

    这题满满的黑科技orz 题意:给出L,要求求出最小的全部由8组成的数(eg: 8,88,888,8888,88888,.......),且这个数是L的倍数 sol:全部由8组成的数可以这样表示:((1 ...

  6. HDU 4483 Lattice triangle(欧拉函数)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4483 题意:给出一个(n+1)*(n+1)的格子.在这个格子中存在多少个三角形? 思路:反着想,所有情 ...

  7. UVa 11426 (欧拉函数 GCD之和) GCD - Extreme (II)

    题意: 求sum{gcd(i, j) | 1 ≤ i < j ≤ n} 分析: 有这样一个很有用的结论:gcd(x, n) = i的充要条件是gcd(x/i, n/i) = 1,因此满足条件的x ...

  8. 【欧拉函数】【HDU1286】 找新朋友

    找新朋友 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submi ...

  9. HDU 1695 GCD(欧拉函数+容斥原理)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1695 题意:x位于区间[a, b],y位于区间[c, d],求满足GCD(x, y) = k的(x, ...

随机推荐

  1. Android - Fragment BackStack 清空

    Fragment BackStack 清空 int backStackCount = getFragmentManager().getBackStackEntryCount(); for(int i ...

  2. Codeforces--629B--Far Relative’s Problem(模拟)

    Far Relative's Problem Time Limit: 2000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I ...

  3. k-means 聚类前的数据分析

    原始数据 Say you are given a data set where each observed example has a set of features, but has nolabel ...

  4. 最新昆石VOS2009/VOS3000手机号段导入文件(手机归属地)

    使用2017年4月最新版手机号段归属地制作,支持所有版本的VOS 共360569条记录,兼容所有版本的昆石VOS,包括VOS2009.vos3000.vos5000 导入比较简单.下载后解压到桌面在V ...

  5. PCB MS SQL表值函数与CLR 表值函数 (例:字符串分割转表)

    将字符串分割为表表经常用到,这里 SQL表值函数与CLR  表值函数,两种实现方法例出来如下: SELECT * FROM FP_EMSDB_PUB.dbo.SqlSplit('/','1oz/1.5 ...

  6. 8.20noip模拟题

    2017-8-20 NOIP模拟赛 by coolyangzc 共3道题目,时间3.5小时 题目名 机器人 数列 虫洞 源文件 robot.cpp/c/pas seq.cpp/c/pas holes. ...

  7. C# 处理oralce 时间

     addWorkSql.Append("to_date(' " + DateTime.Now.ToString("yyyy-MM-dd HH:ss:mm") + ...

  8. BN 详解和使用Tensorflow实现(参数理解)

    Tensorflow   BN具体实现(多种方式): 理论知识(参照大佬):https://blog.csdn.net/hjimce/article/details/50866313 补充知识: ① ...

  9. Lua Time

    -- local getTime = os.date(“%c”); -- %a abbreviated weekday name (e.g., Wed)-- %A full weekday name ...

  10. ES6 arrow function

    语法: () => { … } // 零个参数用 () 表示: x => { … } // 一个参数可以省略 (): (x, y) => { … } // 多参数不能省略 (): 当 ...