Python 백준 알고리즘 1256 : 사전

2023. 2. 15. 15:48·Coding Test

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

 

1256번: 사전

동호와 규완이는 212호에서 문자열에 대해 공부하고 있다. 김진영 조교는 동호와 규완이에게 특별 과제를 주었다. 특별 과제는 특별한 문자열로 이루어 진 사전을 만드는 것이다. 사전에 수록되

www.acmicpc.net

 

# 1256 사전

n, m, k = map(int,input().split())
result = ""
arr = [[1]*(m+1) for _ in range(n+1)]

for i in range(1, n+1):
  for j in range(1, m+1):
    arr[i][j] = arr[i-1][j] + arr[i][j-1]

if arr[n][m] < k:
    print(-1)
else:
  while True:
    if n == 0 or m == 0:
      result += "z"*m
      result += "a"*n
      break
    
    flag = arr[n-1][m]
    if k <= flag:
      result += "a"
      n -= 1
    else:
      result += "z"
      m -= 1
      k -= flag
  print(result)

 

'Coding Test' 카테고리의 다른 글

Python 백준 알고리즘 9252 : LCS 2  (1) 2023.02.15
Python 백준 알고리즘 2193 : 이친수  (1) 2023.02.15
Python 백준 알고리즘 1316 : 그룹 단어 체커  (0) 2023.02.09
Python 백준 알고리즘 2941 : 크로아티아 알파벳  (0) 2023.02.09
Python 백준 알고리즘 5622 : 다이얼  (0) 2023.02.09
'Coding Test' 카테고리의 다른 글
  • Python 백준 알고리즘 9252 : LCS 2
  • Python 백준 알고리즘 2193 : 이친수
  • Python 백준 알고리즘 1316 : 그룹 단어 체커
  • Python 백준 알고리즘 2941 : 크로아티아 알파벳
jhyngu
jhyngu
취업하자.
    티스토리 홈
    |
  • jhyngu
    jhyngu
    jhyngu
  • 글쓰기 관리
  • 전체
    오늘
    어제
    • Dev (151)
      • Java (2)
      • Spring (51)
      • Spring Security (39)
        • JWT (22)
        • OAuth2 (17)
      • Kotlin (2)
      • React (6)
      • Coding Test (28)
      • DB (0)
      • Git (5)
      • Linux (14)
      • docker (3)
  • 블로그 메뉴

    • 홈
    • 태그
    • 방명록
  • 링크

  • 공지사항

  • 인기 글

  • 태그

    JDBC
    react
    JavaScript
    Spring
    백준
    Postman
    git
    Spring Security
    알고리즘
    Linux
    MariaDB
    OAuth2
    mybatis
    JWT
    Spring Framework
    MVC
    oauth2
    Spring Boot
    api client
    spring web
  • hELLO· Designed By정상우.v4.10.3
jhyngu
Python 백준 알고리즘 1256 : 사전
상단으로

티스토리툴바