[백준] 숫자 카드 놀이 20915 python 풀이

YB Lee·2023년 6월 23일
0

코딩테스트

목록 보기
2/2

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

핵심

정리중....

나눠진 두수는

import sys
input = sys.stdin.readline


def solve(num_str):
    a = num_str[0]
    b = num_str[1]

    for i in range(2, len(num_str)):
        if int(a) < int(b):
            a += num_str[i]
        else:
            b += num_str[i]
    return int(a) * int(b)

t = int(input())
for _ in range(t):
    num_str = input().strip()
    num_str = num_str.replace('6', '9')
    num_str = sorted(num_str, key=lambda x:int(x), reverse=True)
    print(solve(num_str))
profile
Those who have a 'why' to live, can bear with almost any 'how'.

0개의 댓글