欧拉函数

学习资料:https://blog.csdn.net/sentimental_dog/article/details/52002608

注意最后一行需要让res/a*(a-1)

因为a本身是可以模a的,但i*i<=a,所以没有枚举到a本身

#include <bits/stdc++.h>
using namespace std;
const int maxn=200000+10;
#define LL long long

int main()
{
    int n;
    LL m;
    ios::sync_with_stdio(0);
    cin>>n;
    for(int i=1;i<=n;i++)
    {
       cin>>m;
       cout<<(m-1)*euler(m)<<endl;
    }
    return 0;
}
View Code

猜你喜欢

转载自www.cnblogs.com/carcar/p/8926107.html