Codeforces Round #628 (Div. 2) A. EhAb AnD gCd(LCM & GCD)
题意:
GCD(a,b) + LCM(a,b) = n,已知 n ,求 a,b。
思路:
设 gcd(a, b) = k, a = xk, b = yk ,
k + ab / k = n
xy = n/k - 1
令 k = 1 , 则 xy = n - 1
令 x = 1 , 则 y = n - 1
∴ a = xk = 1 , b = yk = n-1 一定满足条件。
#include <bits/stdc++.h> using namespace std; typedef long long ll; void solve(){ ll n;cin>>n; cout<<1<<' '<<n-1<<endl; } int main(){ int t;cin>>t; while(t--) solve(); return 0; }