-
C - Professor Agasa Lab
- Gym - 101778C
- 对于正整数N,少于或等于N ([1,N]),且与N互质的正整数(包括1)的个数
- 题意:
- such that a - 1 exists only if gcd(a, m) ≡ 1.
- You are given m, count how many different pairs (a, b) (1 ≤ a, b < m) exist,
-
#include<stdio.h> #include<string.h> const int MAXN=1000010; long long dp[MAXN]; void phi() { memset(dp,0,sizeof(dp)); dp[1]=1; for(int i=2; i<MAXN; i++) { if(dp[i])continue; for(int j=i; j<MAXN; j+=i) { if(!dp[j])dp[j]=j; dp[j]=dp[j]/i*(i-1); } } } int main() { long long N,t; scanf("%lld",&t); while(t--) { scanf("%lld",&N); printf("%lld\n",dp[N]*(N-1)); } return 0; }
C - Professor Agasa Lab-欧拉函数
最新推荐文章于 2021-05-04 17:28:07 发布