问题
Problem Description
Input
Output
Sample Input
2
2 8
10 5
Sample Output
8 1
5 2
题解
两种情况:
1.不用切(x%y==0)。
2.只切草莓(至少要切一刀)变为了2x和y
对2x和y求最小公倍数。
代码
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main()
{
int t;
cin>>t;
while(t--)
{
int x,y;
cin>>x>>y;
if(x%y==0)//不用切
{
cout<<y<<' '<<x/y<<endl;
continue;
}
//只切草莓
//至少切一刀为2x
int k=2x*y/__gcd(2x,y);//最小公倍数
cout<<y<<' '<<k/y<<endl;
}
}