인프런 영문 브랜드 로고
인프런 영문 브랜드 로고

Inflearn Community Q&A

herry10210861's profile image
herry10210861

asked

Introduction to Python Algorithm Problem Solving (Coding Test Preparation)

채점 실행 파일 오류 문의드립니다.

Written on

·

269

0

안녕하세요.
 
첫 번째 섹션의 첫 번째 문제인 "K번째 약수"를 구하는 문제를 풀고 채점 파일을 실행시키니 아래와 같은 에러가 뜨네요.
 
 
 
제가 작성한 코드는 아래와 같으며, 파일명을 AA.py로도 바꿔봤지만 안 됩니다.
# 테스트 케이스용 text 파일을 불러오기 위한 코드
# import sys
# test_file_path = r'C:\Users\XXX\Desktop\Data Science\Study\Algorithm\섹션 2\1. k번째 약수'
# sys.stdin = open(f'{test_file_path}/in1.txt', 'rt')

# 테스트 케이스 데이터 가져오기
n, k = map(int, input().split())

# N의 약수 구하기
num_list = []
for i in range(1, n + 1):
    if n % i == 0:
        num_list.append(i)

# N의 약수 중, K 번째로 작은 수 구하기
if len(num_list) < k:
    print(-1)
else:
    answer = num_list[k - 1]
    print(answer)
python코테 준비 같이 해요!

Answer

This question is waiting for answers
Be the first to answer!
herry10210861's profile image
herry10210861

asked

Ask a question