欧拉函数

A - Bi-shoe and Phi-shoe

欧拉函数为n的合数总大于一个>=n+1的最小素数。有这个定理的证明才可以使用对于每一个数,找>=n+1的最小素数就是所求值,很遗憾,我也不会证明

 1 #include <iostream>
 2 #include <cstring>
 3 #include <string>
 4 #include <map>
 5 #include <set>
 6 #include <algorithm>
 7 #include <fstream>
 8 #include <cstdio>
 9 #include <cmath>
10 #include <stack>
11 #include <queue>
12 using namespace std;
13 const double Pi=3.14159265358979323846;
14 typedef long long ll;
15 const int MAXN=5000+5;
16 const int dx[5]={0,0,0,1,-1};
17 const int dy[5]={1,-1,0,0,0};
18 const int INF = 0x3f3f3f3f;
19 const int NINF = 0xc0c0c0c0;
20 const ll mod=1e9+7;
21 bool isprime(int x)
22 {
23     if(x==1) return false;
24     for(int i=2;i*i<=x;i++)
25     {
26         if(x%i==0) return false;
27     }
28     return true;
29 }
30 
31 int main()
32 {
33     int t;cin>>t;
34     int cnt=0;
35     while(t--)
36     {
37         int n;cin>>n;ll ans=0;
38         while(n--)
39         {
40             int a;scanf("%d",&a);a++;
41             while(!isprime(a)) a++;
42             ans+=a;
43         } 
44         printf("Case %d: %lld Xukha\n",++cnt,ans);
45     }
46     return 0;
47 }

 

posted @ 2019-06-04 18:02  Chuhanjing  阅读(148)  评论(0编辑  收藏  举报