CF337B.Routine Problem

普及/提高-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Manao has a monitor. The screen of the monitor has horizontal to vertical length ratio a:b. Now he is going to watch a movie. The movie's frame has horizontal to vertical length ratio c:d. Manao adjusts the view in such a way that the movie preserves the original frame ratio, but also occupies as much space on the screen as possible and fits within it completely. Thus, he may have to zoom the movie in or out, but Manao will always change the frame proportionally in both dimensions.

Calculate the ratio of empty screen (the part of the screen not occupied by the movie) to the total screen size. Print the answer as an irreducible fraction p / q.

Manao 有一台显示器,其屏幕的宽高比为 a:ba:b。现在他要观看一部电影,该电影画面的宽高比为 c:dc:d。Manao 调整显示方式,使得电影画面保持原始宽高比,同时在完全适配屏幕(即不超出屏幕边界)的前提下尽可能占据最大面积。因此,他可能需要对电影画面进行缩放(放大或缩小),但 Manao 始终会在两个维度上按相同比例缩放画面。

请计算屏幕上未被电影画面占据的空白区域面积与屏幕总面积的比值,并以最简分数形式 pq\frac{p}{q} 输出答案。

输入格式

A single line contains four space-separated integers a, b, c, d (1 ≤ a, b, c, d ≤ 1000).

一行包含四个以空格分隔的整数 aa、bb、cc、dd(1 ≤ a, b, c, d ≤ 10001 ≤ a, b, c, d ≤ 1000)。

输出格式

Print the answer to the problem as "p/q", where p is a non-negative integer, q is a positive integer and numbers p and q don't have a common divisor larger than 1.

以“p/q”的形式输出问题的答案,其中 p 是非负整数,q 是正整数,且 p 与 q 互质(即它们的最大公约数为 1)。

输入输出样例

  • 输入#1

    1 1 3 2

    输出#1

    1/3
  • 输入#2

    4 3 2 2

    输出#2

    1/4

说明/提示

Sample 1. Manao's monitor has a square screen. The movie has 3:2 horizontal to vertical length ratio. Obviously, the movie occupies most of the screen if the width of the picture coincides with the width of the screen. In this case, only 2/3 of the monitor will project the movie in the horizontal dimension:

Sample 2. This time the monitor's width is 4/3 times larger than its height and the movie's frame is square. In this case, the picture must take up the whole monitor in the vertical dimension and only 3/4 in the horizontal dimension:

样例 1:Manao 的显示器屏幕为正方形。电影画面的宽高比为 3:23:2(即水平方向长度与垂直方向长度之比)。显然,当画面宽度恰好等于屏幕宽度时,电影将占据屏幕的大部分区域。此时,在水平方向上,仅有 23\frac{2}{3} 的屏幕区域用于显示电影:

样例 2:此次显示器的宽度是其高度的 43\frac{4}{3} 倍,而电影画面为正方形。此时,画面必须在垂直方向上铺满整个显示器,而在水平方向上仅占据 34\frac{3}{4}:

输入解题思路,AI测评打分。不知道怎么写?

首页