题目链接-B. Omkar and Last Class of Math
题目大意
给你一个数 n n n,求两个数 a , b a,b a,b,使得 a + b = n a+b=n a+b=n且 l c m ( a , b ) lcm(a,b) lcm(a,b)尽可能的小
解题思路
附上代码
#pragma GCC optimize("-Ofast","-funroll-all-loops")
#include
#define int long long
#define lowbit(x) (x &(-x))
#define endl '\n'
using namespace std;
const int INF=0x3f3f3f3f;
const int dir[4][2]={-1,0,1,0,0,-1,0,1};
const double PI=acos(-1.0);
const double e=exp(1.0);
const double eps=1e-10;
const int M=1e9+7;
const int N=2e5+10;
typedef long long ll;
typedef pair<int,int> PII;
typedef unsigned long long ull;
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
int t;
cin>>t;
while(t--){
int n;
cin>>n;
int m=sqrt(n);
bool ass=0;
for(int i=2;i<=m+2&&!ass;i++){
if(n%i==0){
cout<<n/i<<" "<<n-n/i<<endl;
ass=1;
}
}
if(!ass) cout<<1<<" "<<n-1<<endl;
}
return 0;
}