Thứ Tư, 27 tháng 4, 2022

TSNT C++

#include <bits/stdc++.h>
using namespace std;

long long n;

void pt_tsnt()
{
    int i=2;
    while(i<=int(sqrt(n)))
    {
        while (n % i == 0)
        {
            n=n/i;
            cout<<i<<" ";
        }
        i++;
    }
    if(n>1) cout<<n;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    freopen("tsnt.inp","r",stdin);
    freopen("tsnt.out","w",stdout);
    cin>>n;
    pt_tsnt();
    return 0;
}

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.