当前位置:网站首页>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;
}
边栏推荐
- 广州:金融新活水 文企新机遇
- 利尔达低代码数据大屏,铲平数据应用开发门槛
- Why are function templates not partial specialization?
- 电子元器件销售ERP管理系统哪个比较好?
- B_ QuRT_ User_ Guide(26)
- AWS saves data on the cloud (3)
- 个人究竟如何开户炒股?在线开户安全么?
- Kali installation configuration
- Superimposed ladder diagram and line diagram and merged line diagram and needle diagram
- Chenglian premium products donated love materials for flood fighting and disaster relief to Yingde
猜你喜欢

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

【无标题】

如何抑制SiC MOSFET Crosstalk(串擾)?
![[untitled]](/img/bb/213f213c695795daecb81a4cf2adcd.jpg)
[untitled]

TCP

The 6th smart home Asia 2022 will be held in Shanghai in October

VMware Workstation related issues

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

如何抑制SiC MOSFET Crosstalk(串扰)?

AWS saves data on the cloud (3)
随机推荐
关于如何在placeholder中使用字体图标
Usage record of Xintang nuc980: self made development board (based on nuc980dk61yc)
The Falling Leaves
Robot Rapping Results Report
Preparation for Oracle 11g RAC deployment on centos7
Leetcode swing series
如何抑制SiC MOSFET Crosstalk(串擾)?
新唐NUC980使用记录:自制开发板(基于NUC980DK61YC)
Why are function templates not partial specialization?
PLSQL installation under Windows
Loss loss function
Set<String>
Robot Rapping Results Report
In flood fighting and disaster relief, the city donated 100000 yuan of love materials to help Yingde
Unity gets the coordinate point in front of the current object at a certain angle and distance
Super Jumping! Jumping! Jumping!
罗氏线圈工作原理
Infinite penetration test
What are the advantages of a differential probe over a conventional probe
Login common test case