[python]伯準2908号:定数
Problem
https://www.acmicpc.net/problem/2908
Solution
code 1
1つ目の方法は、リストを使用する方法です.
2つ目の方法は、文字列を使用してスライドする方法です.
第1の方法で問題を解決し,別の方法を探す際に第2の方法を知った.リストに変換して文字列に変換する手間もなく、簡単に解決できます.
Ref
https://blockdmask.tistory.com/581
https://www.acmicpc.net/problem/2908
Solution
code 1
1つ目の方法は、リストを使用する方法です.
a, b = input().split()
# 리스트로 변경
a_list = list(a)
b_list = list(b)
# 리스트 뒤집기
a_list.reverse()
b_list.reverse()
# 리스트 -> 문자열 변환
a = ''.join(a_list)
b = ''.join(b_list)
a = int(a)
b = int(b)
print(max(a,b))
code 22つ目の方法は、文字列を使用してスライドする方法です.
a, b = input().split()
a = int(a[::-1])
b = int(b[::-1])
print(max(a,b))
Comment第1の方法で問題を解決し,別の方法を探す際に第2の方法を知った.リストに変換して文字列に変換する手間もなく、簡単に解決できます.
Ref
https://blockdmask.tistory.com/581
Reference
この問題について([python]伯準2908号:定数), 我々は、より多くの情報をここで見つけました https://velog.io/@23tae/Python-백준-2908번-상수テキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol