60分 TLE 大佬求调(玄关)
查看原帖
60分 TLE 大佬求调(玄关)
1802594
Stick_Man_楼主2025/8/4 12:42
#include<bits/stdc++.h>
using namespace std;
#define int long long
inline int read(){
	int x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=x*10+(ch-'0');
		ch=getchar();
	}
	return x*f;
}
inline void print(int x){
	if(x<0){
		putchar('-');
		x=-x;
	}
	if(x>9) print(x/10);
	putchar(x%10+'0');
}
int n;
bool check(int x){
	if(x==2) return true;
	if(x<=1) return false;
	for(int i=2;i<=sqrt(x);i++){
		if(x%i==0) return false;
	}
	return true;
}
signed main(){
    n=read();
    int maxn=INT_MIN;
    for(int i=2;i<=n;i++){
    	int p=n/i;
    	if(check(i)&&check(p)&&p*i==n) maxn=max(maxn,p);
    }
    print(maxn);
    return 0;
}


2025/8/4 12:42
加载中...