백준 온라인 저지, 구현 / 2908번: 상수 (파이썬 / , 백준 브론즈문제)

2022. 1. 2. 15:48알고리즘/구현

728x90
반응형

문제

상근이의 동생 상수는 수학을 정말 못한다. 상수는 숫자를 읽는데 문제가 있다. 이렇게 수학을 못하는 상수를 위해서 상근이는 수의 크기를 비교하는 문제를 내주었다. 상근이는 세 자리 수 두 개를 칠판에 써주었다. 그 다음에 크기가 큰 수를 말해보라고 했다.

상수는 수를 다른 사람과 다르게 거꾸로 읽는다. 예를 들어, 734와 893을 칠판에 적었다면, 상수는 이 수를 437과 398로 읽는다. 따라서, 상수는 두 수중 큰 수인 437을 큰 수라고 말할 것이다.

두 수가 주어졌을 때, 상수의 대답을 출력하는 프로그램을 작성하시오.

입력

첫째 줄에 상근이가 칠판에 적은 두 수 A와 B가 주어진다. 두 수는 같지 않은 세 자리 수이며, 0이 포함되어 있지 않다.

출력

첫째 줄에 상수의 대답을 출력한다.

예제 입력 1

734 893

예제 출력 1

437

예제 입력 2

221 231

예제 출력 2

132

예제 입력 3

839 237

예제 출력 3

938
W3sicHJvYmxlbV9pZCI6IjI5MDgiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWMwYzFcdWMyMTgiLCJkZXNjcmlwdGlvbiI6IjxwPlx1YzBjMVx1YWRmY1x1Yzc3NFx1Yzc1OCBcdWIzZDlcdWMwZGQgXHVjMGMxXHVjMjE4XHViMjk0IFx1YzIxOFx1ZDU1OVx1Yzc0NCBcdWM4MTVcdWI5ZDAgXHViYWJiXHVkNTVjXHViMmU0LiBcdWMwYzFcdWMyMThcdWIyOTQgXHVjMjJiXHVjNzkwXHViOTdjIFx1Yzc3ZFx1YjI5NFx1YjM3MCBcdWJiMzhcdWM4MWNcdWFjMDAgXHVjNzg4XHViMmU0LiBcdWM3NzRcdWI4MDdcdWFjOGMgXHVjMjE4XHVkNTU5XHVjNzQ0IFx1YmFiYlx1ZDU1OFx1YjI5NCBcdWMwYzFcdWMyMThcdWI5N2MgXHVj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3V0cHV0IHNob3VsZCBjb250YWluIHRoZSBsYXJnZXIgb2YgdGhlIG51bWJlcnMgaW4gdGhlIGlucHV0LCBjb21wYXJlZCBhcyBkZXNjcmliZWQgaW4gdGhlIHRhc2suIFRoZSBudW1iZXIgc2hvdWxkIGJlIHdyaXR0ZW4gcmV2ZXJzZWQsIHRvIGRpc3BsYXkgdG8gRmlsaXAgaG93IGhlIHNob3VsZCByZWFkIGl0LjxcL3A+XHJcbiIsImhpbnQiOiIiLCJvcmlnaW5hbCI6IjEiLCJodG1sX3RpdGxlIjoiMCIsInByb2JsZW1fbGFuZ190Y29kZSI6IkVuZ2xpc2gifV0=

접근 방법

- 세자리 수 중 거꾸로 한 수가 작은 수를 출력한다.

코드

# https://www.acmicpc.net/problem/2908
# 접근 방법
# 세자리 수 중 거꾸로 한 수가 작은 수를 출력한다.
a, b= input().split()
a = a[::-1]
b = b[::-1]
print(int(a) if int(a) > int(b) else int(b))
728x90
반응형