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

Muriel ·
更新时间:2024-09-20
· 802 次阅读

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 #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 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; }
作者:Fiveneves



CodeForces AND gcd round div

需要 登录 后方可回复, 如果你还没有账号请 注册新账号