Thứ Năm, 7 tháng 4, 2022

ORIGIN C++


#include <bits/stdc++.h>
using namespace std;
 
long long m;
 
long long goc(long long n)
{
   // cout<<n<<" ";
	long long s = 1;
	for (int i = 2; i <= int(sqrt(n)); i++)
	{
		if(n%i==0) s=s*i;
		while (n%i==0)
			n=n/i;
	}
	if (n>1) s=s*n;
//cout<<s<<endl;
	return s;
}
void giai()
{
    while(m>1){
    	if(goc(m)==m)
    	{
    		cout<<m;
    		return;
    	}
    	m--;
    }
}
int main()
{
//	freopen("goc.inp","r",stdin);
//	freopen("goc.out","w",stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	cin>>m;
	giai();
	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.