标签:max greatest 欧拉函数 syn cep == c++ turn rip
http://acm.hdu.edu.cn/showproblem.php?pid=2588
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 3782 Accepted Submission(s): 2053
1 #include<bits/stdc++.h> 2 using namespace std; 3 #define lson l,mid,rt<<1 4 #define rson mid+1,r,rt<<1|1 5 #define IT set<ll>::iterator 6 #define pb push_back 7 #define eb emplace_back 8 #define maxn 200005 9 #define eps 1e-6 10 #define PI acos(-1.0) 11 #define rep(k,i,j) for(int k=i;k<j;k++) 12 typedef long long ll; 13 typedef pair<int,int> pii; 14 typedef pair<ll,ll>pll; 15 typedef pair<ll,int> pli; 16 typedef pair<pair<int,string>,pii> ppp; 17 typedef unsigned long long ull; 18 const long long MOD=1000000007; 19 const double oula=0.57721566490153286060651209; 20 const int INF=0x3f3f3f3f; 21 using namespace std; 22 23 24 ll Euler(ll n){ 25 ll ans=n; 26 for(ll i=2;i*i<=n;i++){ 27 if(n%i==0) ans=ans/i*(i-1); 28 while(n%i==0) n/=i; 29 } 30 if(n>1) ans=ans/n*(n-1); 31 return ans; 32 } 33 34 int main(){ 35 std::ios::sync_with_stdio(false); 36 int t; 37 cin>>t; 38 while(t--){ 39 ll n,m; 40 cin>>n>>m; 41 ll ans=0; 42 for(int i=1;i*i<=n;i++){ 43 if(n%i==0){ 44 if(i>=m) ans+=Euler(n/i); 45 if(i*i!=n&&n/i>=m) ans+=Euler(i); 46 } 47 } 48 cout<<ans<<endl; 49 } 50 }
标签:max greatest 欧拉函数 syn cep == c++ turn rip
原文地址:https://www.cnblogs.com/Fighting-sh/p/10726914.html