관리 메뉴

솜씨좋은장씨

[BaekJoon] 25814번 : Heavy Numbers (Python) 본문

Programming/코딩 1일 1문제

[BaekJoon] 25814번 : Heavy Numbers (Python)

솜씨좋은장씨 2022. 12. 9. 12:54
728x90
반응형

코딩 1일 1문제! 오늘의 문제는 백준의 Heavy Numbers 입니다.

 

25814번: Heavy Numbers

There is only one input line; it contains two integers separated by exactly one space (blank). Assume each integer is between 1 and 1,000,000 (inclusive).

www.acmicpc.net

👨🏻‍💻 코드 ( Solution )

def calculate_weight(num):
    weight = len(str(num)) * sum(list(map(int, list(str(num)))))
    
    return weight

def heavy_numbers(num1, num2):
    answer = 0
    
    weight_1 = calculate_weight(num=num1)
    weight_2 = calculate_weight(num=num2)
    
    if weight_1 > weight_2:
        answer = 1
    elif weight_1 < weight_2:
        answer = 2
        
    return answer


if __name__ == "__main__":
    num1, num2 = map(int, input().split())
    
    print(heavy_numbers(num1=num1, num2=num2))
 

GitHub - SOMJANG/CODINGTEST_PRACTICE: 1일 1문제 since 2020.02.07

1일 1문제 since 2020.02.07. Contribute to SOMJANG/CODINGTEST_PRACTICE development by creating an account on GitHub.

github.com

Comments