2 条题解

  • 1
    @ 2023-9-30 13:05:11

    太裤啦

    #include<cstdio>
    #include<cstring>
    #include<iostream>
    #include<algorithm>
    using namespace std;
    typedef long long ll;
    ll get_oula(int x)
    {
        ll ans = x;
        for(int i = 2;i <= x / i;i++)
        {
            if(x % i == 0) ans = 1ll * ans / i * (i - 1);
            while(x % i == 0) x /= i;
        }
        if(x > 1) ans = ans / x * (x - 1);
        return ans;
    }
    int main()
    {
        int n;scanf("%d",&n);
        ll ans = 0;
        for(int d = 1;d <= n / d;d++)
        {
            if(n % d == 0)
            {
                ans += 1ll * (n / d) * get_oula(d);
                int c = n / d;
                if(d != c) ans += 1ll * d * get_oula(c);
            }
        }
        cout << ans << endl;
        return 0;
    }
    
    
    • @ 2023-10-15 18:05:09

      哟西,大大的好

  • 0
    @ 2026-11-19 21:57:24

    wow

    #include<bits/stdc++.h>
    #define int long long
    using namespace std;
    int phi(int x){
    	int ret=x;
    	for(int i=2;i*i<=x;i++)
    		if(x%i==0){
    			ret=ret*(i-1)/i;
    			while(x%i==0)x/=i;
    		}
    	if(x>1)ret=ret*(x-1)/x;
    	return ret;
    }
    int n,ans;
    signed main(){
    	cin>>n;
    	for(int i=1;i*i<=n;i++)
    		if(n%i==0){
    			ans+=i*phi(n/i);
    			if(i*i!=n)
    				ans+=n/i*phi(i);
    		}
    	cout<<ans;
    	return 0;
    }
    
    • 1

    信息

    ID
    132
    时间
    1000ms
    内存
    128MiB
    难度
    2
    标签
    递交数
    27
    已通过
    22
    上传者