标签:
2 1
3 2
2 1
1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 using namespace std; 5 #define MOD 1000000007 6 #define ll long long 7 ll eular(ll n) 8 { 9 ll res=1; 10 for(ll i=2;i*i<=n;i++) 11 { 12 if(n%i==0) 13 { 14 n/=i,res*=i-1; 15 while(n%i==0) 16 { 17 n/=i; 18 res*=i; 19 } 20 } 21 } 22 if(n>1) res*=n-1; 23 return res; 24 } 25 ll n,k; 26 int main() 27 { 28 while(scanf("%I64d%I64d",&n,&k)==2) 29 { 30 if(k==2 || n==1) 31 { 32 printf("1\n"); 33 continue; 34 } 35 if(k>2) 36 { 37 printf("0\n"); 38 continue; 39 } 40 41 ll ans=0; 42 for(ll i=1;i*i<=n;i++) 43 { 44 if(n%i==0) 45 { 46 if(i*i!=n) 47 ans=(ans+eular(n/i)*eular(i)*2)%MOD; 48 else 49 ans=(ans+eular(n/i)*eular(i))%MOD; 50 } 51 } 52 printf("%I64d\n",ans); 53 54 } 55 return 0; 56 }
标签:
原文地址:http://www.cnblogs.com/UniqueColor/p/4735021.html