Блог пользователя dnazirzhanov05

Автор dnazirzhanov05, история, 4 года назад, перевод, По-русски

Please , help to solve this problem.

Flag

The ratio of length to width of the national flag of Berland is 5:3.For a given natural number K (the length or width of the flag), find its area (as a natural number or a mixed fraction with the lowest possible denominator).

Input data format :** natural number K, 2 <= K <= 100. If K <= 50, this is the width, otherwise it is the length.

Output format : a single integer or three natural numbers (the integer part, the numerator and denominator) Examples : 8 ---> 106 2 3

75 ---> 3375

  • Проголосовать: нравится
  • +1
  • Проголосовать: не нравится

»
4 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

If k <= 50, it is $$$5k^2/3$$$
Else it is $$$3k^2/5$$$

In each case just calculate the numerator and see if it is divisible by the denominator.

  • if it is then print the quotient

  • otherwise print (num/denom) (num%denom) (denom)