그래서 CodeChef에서 경쟁력있는 프로그래밍을 사용하기로 결정했습니다. 나는 시도 할 문제를 보았다. 하지만 런타임 오류 (NZEC) 점점 계속 왜 내가 너무 많은 메모리를 사용하는 끝없는 루프 및 루프 된 배열 항목을 호출 할 때 오류가 발생했을 때 나는 생각하지 않습니다.Python : HELP 런타임 오류 발생 (NZEC)
문제
1) 2 개 입력 A와 B
2) 경계 가져 오기 : 1 ≤ B < ≤ 10000
3) 그럼 내가 할 AB를하고 응답의 한 자리를 변경 1 초, 최대 소스 코드 크기가
예를 들어
,369을 50,000bytes 시간 제한이있다 :4.) 그리고 나는 그것이
참고 반환
input A >> 95
input B >> 50
output >> 35
실제 대답은 45 만 그래서 내 솔루션
from random import randint
test1 = True
test2 = True
while test1:
A = int(input("Enter a number: "))
if (A>=1) and (A<=10000):
test1 = False
else:
print("Number must be greater or equal to 1 and less than or equalts to 10,000")
while test2:
B = int(input("Enter a second number: "))
if (B>=1) and (B<=10000) and (B<A):
test2 = False
else:
print("Number must follow rules as above BUT must be less than your first")
solution = str(A-B)
range1 = randint(0, len(solution)-1)
range2 = randint(0,9)
replacement = list(range(0,10))
new_solution = solution.replace(solution[range1], str(replacement[range2]))
print(new_solution)
다른 답변을 살펴 보았습니다. 사용자가 경계를 따라 간다면 테스트 용 코드도 포함되지 않았습니다. 그래서 확실히, 문자열 입력 테스트는 아마도 런타임 제한 문제는 아니지만 확실하지 않습니다. –