当前位置:网站首页>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;
}
边栏推荐
- Case tool
- B_ QuRT_ User_ Guide(27)
- Map. ToCharArray( ),Map. getOrDefault(). Map. charAt()
- 整数划分
- [cloud native | kubernetes] in depth understanding of pod (VI)
- After installing NRM, the internal/validators js:124 throw new ERR_ INVALID_ ARG_ TYPE(name, ‘string‘, value)
- Modifying the SSH default port when installing Oracle RAC makes CRS unable to install
- Login common test case
- Cloudcompare & PCL point cloud clipping (based on closed surfaces or polygons)
- The 6th smart home Asia 2022 will be held in Shanghai in October
猜你喜欢

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

TCP那点事

Kubernetes notes and the latest k3s installation introduction
![[cloud native | kubernetes] in depth understanding of pod (VI)](/img/ae/f16f5c090251ab603b88ddadff7eb3.png)
[cloud native | kubernetes] in depth understanding of pod (VI)

【云原生 | Kubernetes篇】深入了解Pod(六)

Operating principle of Rogowski coil

块级元素上下左右居中的两个小技巧

About using font icons in placeholder

Quelle est la largeur de bande du serveur de bavardage sonore pour des centaines de millions de personnes en même temps?

What are the advantages of a differential probe over a conventional probe
随机推荐
[learning notes] search
Infinite penetration test
B_ QuRT_ User_ Guide(26)
VMware Workstation related issues
抖音服務器帶寬有多大,才能供上億人同時刷?
关于如何在placeholder中使用字体图标
WasmEdge 0.10.0 发布!全新的插件扩展机制、Socket API 增强、LLVM 14 支持
Cloudcompare & PCL point cloud clipping (based on closed surfaces or polygons)
Children's unit of 2022 Paris fashion week ended successfully at Wuhan station on June 19
About RAC modifying scan IP
Kali installation configuration
TCP那点事
Selenium reptile
A - Bi-shoe and Phi-shoe
About ASM disk space full, clean up ASM disk
Installing MySQL under Linux
[learning notes] linear basis
安装nrm后,使用nrm命令报错internal/validators.js:124 throw new ERR_INVALID_ARG_TYPE(name, ‘string‘, value)
神殿
Sword finger offer 30 Stack containing min function