2 條題解

  • -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;
    }
    

    資訊

    ID
    185
    時間
    1000ms
    記憶體
    256MiB
    難度
    3
    標籤
    (無)
    遞交數
    44
    已透過
    14
    上傳者