Water, just know (x, y) the number of points on the line that corresponds to the endpoint is gcd (x, y) +1 (which contains two endpoints), knowing that the Euler function goes
#include <cstdio>#include <iostream>#include <cstring>#include <algorithm>#include <set>#include <queue>#include <map>using namespace STD;#define MAX (x, Y) ((() > (y))? ( x):(y))#define MIN (x, y) ((< (y))? ( x):(y))#define N 500010#define PI ACOs ( -1.0)#define INF 100000000typedef Long Longlltypedef unsigned Long LongUllintphi[1010];voidPhi_table (intN) { for(intI=2; i<=n;i++) phi[i]=0; phi[1]=1; for(intI=2; i<=n;i++) {if(!phi[i]) for(intJ=i;j<=n;j+=i) {if(!phi[j]) phi[j]=j; phi[j]=phi[j]/i* (I-1); }}}ll ans[1010];intMain () {phi_table ( +); for(intI=1; i<= +; i++) ans[i]=ans[i-1]+phi[i];intT,n;scanf("%d", &t); for(intCount=1; count<=t;count++) {scanf("%d", &n);printf("%d%d%lld\n", count,n,ans[n]*2+1); }return 0;}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
poj_3090_ Euler function