每一个数字的欧拉函数要大于或等于该数字。求,最小的欧拉函数的下标和的大小。
答案要用longlong存
1 #include <iostream> 2 #include <algorithm> 3 #include <cstring> 4 #include <cstdio> 5 #include <string> 6 #include <map> 7 #include <cmath> 8 #include <vector> 9 10 #define Faster ios::sync_with_stdio(false),cin.tie(0) 11 #define Read freopen("in.txt","r",stdin),freopen("out.txt","w",stdout) 12 #define Close fclose(stdin),fclose(stdout) 13 const int maxn = 1e6 + 5; 14 using namespace std; 15 const int MOD = 1e9+7; 16 typedef long long ll; 17 18 int a[maxn]; 19 ll euler[maxn]; 20 bool isPrime[maxn]; 21 ll mp[maxn]; 22 23 void Init(){ 24 euler[1]=1; 25 for(int i=2;i<maxn;i++) 26 euler[i]=i; 27 for(int i=2;i<maxn;i++) 28 if(euler[i]==i) 29 for(int j=i;j<maxn;j+=i) 30 //euler[j]=euler[j]/i*(i-1);//先进行除法是为了防止中间数据的溢出 31 euler[j] -= euler[j] / i; 32 } 33 34 int main(){ 35 Faster; 36 Init(); 37 int t; 38 cin >> t; 39 int cnt = 0; 40 while(t--){ 41 cnt++; 42 int n; 43 cin >> n; 44 ll ans = 0; 45 for(int i = 0;i < n;i++){ 46 // int x; 47 cin >> a[i]; 48 } 49 sort(a, a+n); 50 int j = 2; 51 for(int i = 0;i < n;i++){ 52 for(;j < maxn;j++){ 53 if(euler[j] >= a[i]){ 54 ans += j; 55 break; 56 } 57 } 58 } 59 cout << "Case " << cnt << ": " << ans << " Xukha" << endl; 60 } 61 return 0; 62 }