当前位置:网站首页>A - Bi-shoe and Phi-shoe
A - Bi-shoe and Phi-shoe
2022-06-28 08:35:00 【Angeliaaa】
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
The question : give n A lucky number , Find the Euler function whose value is greater than or equal to these lucky numbers x, send x The minimum value of .
Ideas : Because the value of the Euler function of a prime number is its minus 1, This problem is to find the smallest prime number greater than the lucky number , And then add it up . First run a prime number to print the table , Then find the smallest prime number greater than the lucky number , Add up , Finally come to the answer . The code is as follows :
#include<stdio.h>
#include<string.h>
int a[1000010];
int b[1000010];
int main()
{
int T,n,i,j,t,k=1;
memset(a,0,sizeof(a));
for (i = 2; i<=1000010; i++)
{
if (a[i]==0) //0 Prime number
{
for (j=i+i; j<=1000010; j+=i)
a[j]=1;
}
}
a[1]=1;
scanf("%d",&T);
while(T--)
{
long long int sum=0;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&b[i]);
for(j=b[i]+1;;j++) // Add here 1, Otherwise t-1 It may be less than b[i];
{
if(a[j]==0)
{
t=j;
break;
}
}
sum=sum+t;
}
printf("Case %d: %lld Xukha\n",k++,sum);
}
return 0;
}
边栏推荐
- Trailing Zeroes (II)
- Mysql8.0 forgot the root password
- ffmpeg推流报错Failed to update header with correct duration.
- B_ QuRT_ User_ Guide(29)
- [learning notes] search
- 【转载】STM32 GPIO类型
- A - Bi-shoe and Phi-shoe
- 微内核Zephyr获众多厂家支持!
- IO error in Oracle11g: got minus one from a read call
- AWS builds a virtual infrastructure including servers and networks (2)
猜你喜欢

B_ QuRT_ User_ Guide(28)

MySQL8.0 忘记 root 密码

利尔达低代码数据大屏,铲平数据应用开发门槛

Superimposed ladder diagram and line diagram and merged line diagram and needle diagram
![[untitled]](/img/bb/213f213c695795daecb81a4cf2adcd.jpg)
[untitled]

电子元器件销售ERP管理系统哪个比较好?

Set the encoding of CMD to UTF-8

What is the bandwidth of the Tiktok server that can be used by hundreds of millions of people at the same time?

Wasmedge 0.10.0 release! New plug-in extension mechanism, socket API enhancement, llvm 14 support

Build an integrated kubernetes in Fedora
随机推荐
Mysql8.0 forgot the root password
Modifying the SSH default port when installing Oracle RAC makes CRS unable to install
Infinite penetration test
Trailing Zeroes (II)
[learning notes] shortest path + spanning tree
【Go ~ 0到1 】 第二天 6月25 Switch语句,数组的声明与遍历
nuxt3入门
AWS saves data on the cloud (3)
B_ QuRT_ User_ Guide(26)
[go ~ 0 to 1] the third day June 27 slice, map and function
隐私计算FATE-----离线预测
罗氏线圈可以测量的大电流和频率范围
Solve NPM err! Unexpected end of JSON input while parsing near
Force buckle 1884 Egg drop - two eggs
【.NET6】gRPC服务端和客户端开发案例,以及minimal API服务、gRPC服务和传统webapi服务的访问效率大对决
Tree
webrtc优势与模块拆分
CloudCompare&PCL 点云裁剪(基于封闭曲面或多边形)
How do people over 40 allocate annuity insurance? Which product is more suitable?
Redis deployment under Linux & redis startup