Logo
(追記) (追記ここまで)

9297번 - Reducing Improper Fractions 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB98749346549.893%

문제

You were invited to a St. Patrick’s Day party, but you aren’t allowed to leave until you finish your fraction reduction homework. You want to go to the party as soon as possible so you decide to write a program to do your homework for you. Given an improper fraction, calculate its reduced form.

입력

The first line of input is the number of test cases that follow. Each test case is a line containing two integer values. The first integer value will be the numerator n (0 ≤ n ≤ 109), the second integer is the denominator d (0 < d ≤ 109).

출력

For each case output the line “Case x:” where x is the case number, on a single line, followed by a space, and then proper fraction. Each fraction will be of the form “I N/D”, where I is the integer part, N is the numerator of the fractional part, and D is the denominator of the fractional part. If the integer value is equal to 0, only output “N/D”. If both the integer value and the reduced numerator are zero, output “0”. If there is no fractional part, only output “I”.

제한

예제 입력 1

4
301 100
89 39
50 25
25 50

예제 출력 1

Case 1: 3 1/100
Case 2: 2 11/39
Case 3: 2
Case 4: 25/50

힌트

출처

School > University of Virginia High School Programming Contest > UVa HSPC 2012 B번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /