CF1041B Buying a TV Set

    • 163通过
    • 197提交
  • 题目来源 CodeForces 1041B
  • 评测方式 RemoteJudge
  • 标签 枚举,暴力
  • 难度 普及/提高-
  • 时空限制 1000ms / 256MB

题解

  • 提示:收藏到任务计划后,可在首页查看。
  • 最新讨论 显示

    推荐的相关题目 显示

    题意翻译

    题目大意:

    给你$a,b,c,d$,求满足$\frac{x}{y}=\frac{c}{d},x\leq a,y\leq b$的$x,y$的对数

    输入格式:

    一行$4$个整数$a,b,c,d$

    输出格式:

    一个整数,表示满足条件的对数

    题目描述

    Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than $ a $ and screen height not greater than $ b $ . Monocarp is also used to TV sets with a certain aspect ratio: formally, if the width of the screen is $ w $ , and the height of the screen is $ h $ , then the following condition should be met: $ \frac{w}{h} = \frac{x}{y} $ .

    There are many different TV sets in the shop. Monocarp is sure that for any pair of positive integers $ w $ and $ h $ there is a TV set with screen width $ w $ and height $ h $ in the shop.

    Monocarp isn't ready to choose the exact TV set he is going to buy. Firstly he wants to determine the optimal screen resolution. He has decided to try all possible variants of screen size. But he must count the number of pairs of positive integers $ w $ and $ h $ , beforehand, such that $ (w \le a) $ , $ (h \le b) $ and $ (\frac{w}{h} = \frac{x}{y}) $ .

    In other words, Monocarp wants to determine the number of TV sets having aspect ratio $ \frac{x}{y} $ , screen width not exceeding $ a $ , and screen height not exceeding $ b $ . Two TV sets are considered different if they have different screen width or different screen height.

    输入输出格式

    输入格式:

    The first line contains four integers $ a $ , $ b $ , $ x $ , $ y $ ( $ 1 \le a, b, x, y \le 10^{18} $ ) — the constraints on the screen width and height, and on the aspect ratio.

    输出格式:

    Print one integer — the number of different variants to choose TV screen width and screen height so that they meet the aforementioned constraints.

    输入输出样例

    输入样例#1: 复制
    17 15 5 3
    
    输出样例#1: 复制
    3
    
    输入样例#2: 复制
    14 16 7 22
    
    输出样例#2: 复制
    0
    
    输入样例#3: 复制
    4 2 6 4
    
    输出样例#3: 复制
    1
    
    输入样例#4: 复制
    1000000000000000000 1000000000000000000 999999866000004473 999999822000007597
    
    输出样例#4: 复制
    1000000063
    

    说明

    In the first example, there are $ 3 $ possible variants: $ (5, 3) $ , $ (10, 6) $ , $ (15, 9) $ .

    In the second example, there is no TV set meeting the constraints.

    In the third example, there is only one variant: $ (3, 2) $ .

    提示
    标程仅供做题后或实在无思路时参考。
    请自觉、自律地使用该功能并请对自己的学习负责。
    如果发现恶意抄袭标程,将按照I类违反进行处理。