Thứ Hai, 16 tháng 5, 2022

PSTG C++


#include <bits/stdc++.h>
using namespace std;
long long n;
void pt_tsnt()
{
    int res=n;
    int i=2;
    while(i<=int(sqrt(n)))
    {
        if(n%i==0)
        {
            while (n % i == 0) n=n/i;
            res=res*(i-1)/i;
        }
        i++;
    }
    if(n>1) res=res*(n-1)/n;
    cout<<res;
}


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);

    freopen("pstg.inp","r",stdin);
    freopen("pstg.out","w",stdout);

    cin >> n;
    pt_tsnt();
}

Không có nhận xét nào:

Đăng nhận xét

Lưu ý: Chỉ thành viên của blog này mới được đăng nhận xét.