Gym - 101257D !Hasan

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?

Input

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.

Output

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.

Example
Input
5 3 4
Output
9
Input
100 10 1
Output

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;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值