题解 | #游游的最小公倍数#

游游的最小公倍数

https://www.nowcoder.com/practice/385c7aa397e54bb58f36286ab0d65156

要等于,且 要尽可能接近

#include<bits/stdc++.h>
#define int long long
#define double long double
#define x first
#define y second
using namespace std;
typedef long long LL;
typedef long long ll;
typedef pair<int,int> PII;
const int N=3e5+10;
const int M=1e3+10;
int mod=1e9+7;
int a[N];

void solve(){
    int n;cin>>n;
    int x=n/2,y=n-x;
    while(__gcd(x,y)!=1){
        x--;y++;
    }
    cout<<x<<" "<<y<<"\n";
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    int _;
    _=1;
    cin>>_;
    while(_--){
        solve();
    }
}
全部评论

相关推荐

10-28 10:48
已编辑
门头沟学院 Java
孩子我想要offer:发笔试后还没笔试把我挂了,然后邮箱一直让我测评没测,后面不知道干嘛又给我捞起来下轮笔试,做完测评笔试又挂了😅
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务