欧拉函数模板
#include<bits/stdc++.h> using namespace std; int n,k,p[200002],ans; int cnt,c; vector<int> v; void phi() { for(int i=2; i<=n; i++) p[i] = 0; p[1] = 1; for(int i=2; i<=n; i++) if(!p[i]){ for(int j=i; j<=n; j+=i){ if(!p[j]){ p[j] = j; } p[j] = p[j] / i * (i - 1); } } } int main() { cin >> n; phi(); for(int i=1; i<=n; i++) cout << i <<": "<< p[i] << endl; return 0;; } /* 12 4 1 5 7 11 10 4 1 3 7 9 4 2 1 3 20 1: 1 2: 1 3: 2 4: 2 5: 4 6: 2 7: 6 8: 4 9: 6 10: 4 11: 10 12: 4 13: 12 14: 6 15: 8 16: 8 17: 16 18: 6 19: 18 20: 8 */