티스토리 뷰

728x90

https://www.acmicpc.net/problem/5648

 

5648번: 역원소 정렬

모든 원소가 양의 정수인 집합이 있을 때, 원소를 거꾸로 뒤집고 그 원소를 오름차순으로 정렬하는 프로그램을 작성하세요. 단, 원소를 뒤집었을 때 0이 앞에 선행되는 경우는 0을 생략해야합니

www.acmicpc.net

 

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
lst = []
n, idx = 10**6, 0
while True:
    if len(lst) == n:
        break
    tmp_i = 0
    for i in list(map(int, input().split())):
        if idx == 0 and tmp_i == 0:
            n = i
            tmp_i += 1
            idx += 1
        else:
            tmp = int(''.join(reversed(str(i))))
            lst.append(tmp)
lst.sort()
for i in lst:
    print(i)
cs

 

 

댓글