아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Sequinary Numerals

면접 대비

시간 제한1초메모리 제한1024 MB

요약
3/2진법 숫자를 정확한 분수로 바꾼 뒤 정수 부분을 분리하고 나머지를 기약분수로 줄인다.
난이도

보통10점 중 5점

유형
수학, 정수론, 구현, 문자열
정답자
아직 제출이 없습니다

문제

A sequinary numeral is a sequence of digits:

dndn-2...d1d0

where dn is 1 or 2 and the others are 0, 1, or 2.

It represents the rational number:

d0 + d1 * (3/2) + d2 * (3/2)2 + ... + dn * (3/2)n

Write a program which takes a sequinary numeral as input and returns the number it represents as a proper fraction.

입력

The single line of input contains a sequinary numeral of no more than 32 digits.

출력

Output consists of a single line.

If the result is an integer, the output is the decimal integer. Otherwise, the output is N a single space and K/M where N, K and M are decimal integers where K < M and K/M is in lowest terms (GCD(K, M) = 1).

예제2

  1. 예제 1

    입력
    2101
    
    예상 출력
    10
    
  2. 예제 2

    입력
    201
    
    예상 출력
    5 1/2