hdu 4279 Number (欧拉函数 - 概数个数)
hdu 4279 Number (欧拉函数 - 约数个数)
详解请戳 点击打开链接
mark 一下 当n>2的时候 所有的n的欧拉函数的个数都是一个偶数
约数的个数只有当n为完全平方数的时候是奇数个
其他情况下为偶数个
#include <iostream> #include <cmath> #include <cstdio> typedef long long LL; using namespace std; LL solve(LL x) { if(x<6)return 0; LL tmp = (LL)sqrt(x*1.0); LL ans = x/2-2; if(tmp&1)ans++; return ans; } int main() { LL A,B; LL T; cin>>T; while(T--) { cin>>A>>B; cout<<solve(B)-solve(A-1)<<endl; } return 0; }