15 solutions

  • 3
    @ 2022-1-6 20:43:25

    首先给出的数如果是素数那么就不能拆成两个数相乘那么此时的x就只能为该数本身,若不是素数那么拆成的两个数还需判断是否能整除

    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
    	long long n;
    	cin>>n;
    	if(n<=3) cout<<n;
    	else{
    		long long l=0x3f3f3f3f3f3f;
    		int ox=0;
    		for(long long c=2;c*c<=n;c++){
    			if(n%c==0){
    				long long k=n/c;
    				if(k%c==0){
    					ox=1;
    					long long p=k/c;
    					l=min(l,p);
    				}
    			}
    		}
    	if(ox) cout<<l;
    	else cout<<n;
    	}
    	return 0;
    }
    

    Information

    ID
    189
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    8
    Tags
    # Submissions
    493
    Accepted
    91
    Uploaded By