Notice
Recent Posts
Recent Comments
Link
나의 개발일지
[백준] 1111번 IQ Test [Python, 파이썬] 본문
- 문제 : https://www.acmicpc.net/problem/1111
- 완전 탐색 알고리즘
- 예외) A인 경우
- n == 1
- n == 2 and 두 수가 다른 경우
- 반복문 i와 j의 범위는 질문 게시판을 통해 알아냄..
n = int(input())
test = list(map(int, input().split()))
if n == 2 and test[0] != test[1] or n == 1:
print('A')
exit()
for i in range(-200, 201):
for j in range(-20000, 20001):
if test[0] * i + j == test[1]:
sw = 0
for k in range(n-1):
if test[k] * i + j != test[k+1]:
sw = 1
break
if sw == 0:
print(test[n-1] * i + j)
exit()
print('B')
'백준' 카테고리의 다른 글
[백준] 1477 휴게소 세우기 [Python, 파이썬] (0) | 2023.09.06 |
---|---|
[백준] 9205번 맥주 마시면서 걸어가기 [Python, 파이썬] (0) | 2023.09.05 |
[백준] 13305번 주유소 [Python] (0) | 2023.08.04 |
[백준] 2294번 동전 2 [Python] (0) | 2023.08.04 |
[백준] 1939번 중량제한 [Python] (0) | 2023.08.04 |
Comments