본문 바로가기
Algorithm

[자료구조/해시] 백준 20232 Archivist - 파이썬(Python)

by jangThang 2022. 7. 31.
반응형

백준 온라인 저지

 

[ Contents ]

     

     

    1. 문제 (링크 참조)

     

    20232번: Archivist

    The only line of input contains a single integer $y$ ($1995 \le y \le 2019$), denoting the year. You don't need to process year numbers less than $1995$ or greater than $2019$, or incorrect year formats. It is guaranteed that you will be given a number bet

    www.acmicpc.net

     

     

     

    2. 문제 풀이

     1995년부터 2019년까지의 대회 수상자의 이름이 문제에 주어집니다. 년도가 입력되면, 해당 연도의 수상자를 출력합니다.

     

     

     

    3. 코드

    # 입력
    y = int(input())
    
    # 수상자 목록
    award_dict = {1995: 'ITMO',
    1996: 'SPbSU',
    1997: 'SPbSU',
    1998: 'ITMO',
    1999: 'ITMO',
    2000: 'SPbSU',
    2001: 'ITMO',
    2002: 'ITMO',
    2003: 'ITMO',
    2004: 'ITMO',
    2005: 'ITMO',
    2006: 'PetrSU, ITMO',
    2007: 'SPbSU',
    2008: 'SPbSU',
    2009: 'ITMO',
    2010: 'ITMO',
    2011: 'ITMO',
    2012: 'ITMO',
    2013: 'SPbSU',
    2014: 'ITMO',
    2015: 'ITMO',
    2016: 'ITMO',
    2017: 'ITMO',
    2018: 'SPbSU',
    2019: 'ITMO'}
    
    # 출력
    print(award_dict[y])

     딕셔너리 구조를 이용하면 쉽게 구현할 수 있습니다.. 오히려 딕셔너리를 일일이 쓰는 게 더 어렵겠네요.

     

    2022.04.12 - [PL (Programming Language)/Python] - [Python] 파이썬 딕셔너리(Dictionary) 연산 및 메서드

     

    [Python] 파이썬 딕셔너리(Dictionary) 연산 및 메서드

    파이썬 딕셔너리 자료형에 대해 알아보고, 관련 연산과 메서드까지 살펴보겠습니다. [ Contents ] 1. 딕셔너리(Dictionary)란? 딕셔너리 명 = {key1: value1, key2: value2, ...}  딕셔너리는 파이썬에서 기본으..

    star7sss.tistory.com

     

     

    star가 되고나서 Tistory

    반응형

    댓글