junior19

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

D. !Hasan
time limit per test
0.25 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

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 Yminutes 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, NX, 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.

Examples
input
5 3 4
output
9
input
100 10 1
output
91

思路:两个人的工作是互不影响的,因此考虑二分时间,判断某时间内两人一共弄好几台电脑。

# include <iostream>
# include <cstdio>
# include <cstring>
# include <cmath>
# include <vector>
# include <algorithm>
# define LL long long
# define INF 0x3f3f3f3f
using namespace std;
LL n, x, y;

bool judge(LL mid)
{
    return mid/x + mid/y >= n;
}

int main()
{
    while(~scanf("%I64d%I64d%I64d",&n,&x,&y))
    {
        LL l=0, r=max(x,y)*n, mid;
        while(l<r)
        {
            mid = (l+r)>>1;
            if(judge(mid))
                r = mid;
            else
                l = mid+1;
        }
        printf("%I64d\n",r);
    }
    return 0;
}



posted on 2017-03-01 22:33  junior19  阅读(242)  评论(0)    收藏  举报