#阿里笔试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;
}
全部评论
相关推荐
点赞 评论 收藏
分享
腾讯 普通offer 24k~26k * 15,年包在36w~39w左右。
点赞 评论 收藏
分享
11-01 08:48
门头沟学院 C++ 点赞 评论 收藏
分享