Mixed Dimensions Onsite Round will host N contestants this year.
Moath and Saif have been preparing the contest hall, Moath needs X minutes to set up a computer for the contest, while Saif needs Y minutes to set up a computer. Each one of them works separately on one computer at a time.
Hasan is concerned they won't finish setting up the PCs in time, can you help Hasan figure out the minimum time required by Moath and Saif to set up all N PCs for the contest?
The input contains 3 integers, N, X, and Y (1 ≤ N, X, Y ≤ 109), the number of PCs to set up, the amount of minutes Moath needs to set up a computer, and the amount of minutes Saif needs to set up a computer, respectively.
On a single line, print one integer, the minimum number of minutes required by Moath and Saif to set up all the PCs for the contest.
5 3 4
9
100 10 1
91
题意:一共有n台电脑需要调试,甲调试一台需要x分钟,乙调试一台需要y分钟,问调试完全部电脑最少需要多少分钟
思路:二分结果即可
ac代码:
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
int main()
{
long long n,x,y;
scanf("%lld %lld %lld",&n,&x,&y);
long long l=0,r =min(x,y)*n+100;
while(l<r-1)
{
long long mid = (l+r)/2;
long long tmp = mid/x+mid/y;
if(tmp>=n)
r = mid;
else
l = mid;
}
printf("%lld\n",r);
return 0;
}