2 solutions

  • -1
    @ 2024-10-5 10:05:19
    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
        int n;
        cin>>n;
        while(n--)
        {
            int x;
            cin>>x;
            int s=x;
            for(int i=2;i<=x/i;i++)
            {
                if(x%i==0)
                {
                    s=s/i*(i-1);
                    while(x%i==0)
                    {
                        x/=i;
                    }
                }
            }
            if(x>1)
            {
                s=s/x*(x-1);
            }
            cout<<s<<endl;
        }
        
        return 0;
    }
    

    Information

    ID
    185
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    3
    Tags
    (None)
    # Submissions
    43
    Accepted
    13
    Uploaded By