#阿里笔试2020#
8.24 第一题ac代码;第二题太长了都没做;
#include
using namespace std;
using ll = long long;
int gcd(int a, int b)
{
if (b == 0)
{
return a;
}
return gcd(b, a % b);
}
int main()
{
ll A, B, a, b;
cin >> A >> B >> a >> b;
int flag = 0;
int m = gcd(a, b);
a = a / m;
b = b / m;
ll n1 = A / a;
ll n2 = B / b;
ll res = min(n1, n2);
if (res >= 1)
{
cout << res * a << " " << res * b << endl;
}
else
{
cout << "0 0" << endl;
}
return 0;
}
8.24 第一题ac代码;第二题太长了都没做;
#include
using namespace std;
using ll = long long;
int gcd(int a, int b)
{
if (b == 0)
{
return a;
}
return gcd(b, a % b);
}
int main()
{
ll A, B, a, b;
cin >> A >> B >> a >> b;
int flag = 0;
int m = gcd(a, b);
a = a / m;
b = b / m;
ll n1 = A / a;
ll n2 = B / b;
ll res = min(n1, n2);
if (res >= 1)
{
cout << res * a << " " << res * b << endl;
}
else
{
cout << "0 0" << endl;
}
return 0;
}
全部评论
相关推荐
点赞 评论 收藏
分享
11-27 23:26
湖北商贸学院 游戏前端 点赞 评论 收藏
分享