Codeforces Round #628 (Div. 2) A. EhAb AnD gCd

A. EhAb AnD gCd

题目链接-A. EhAb AnD gCd
在这里插入图片描述
题目大意
输入一个正整数x,找出这样的2个正整数a和b,使得gcd(a,b)+lcm(a,b)=x
解题思路
找最特殊的情况a=1,b=x-1即可
这样a,b两个数最大公因数为1,最小公倍数x-1,满足题意√

附上代码

#include<bits/stdc++.h>
#define int long long
#define lowbit(x) (x &(-x))
using namespace std;
const int INF=0x3f3f3f3f;
const double PI=acos(-1.0);
const double eps=1e-10;
const int M=1e9+7;
const int N=1e5+5;
typedef long long ll;
typedef pair<int,int> PII;
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	
	int t;
	cin>>t;
	while(t--){
		int n;
		cin>>n;
		cout<<1<<" "<<n-1<<endl;
	}
	return 0;
}
发布了123 篇原创文章 · 获赞 9 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/Fiveneves/article/details/104872407