9037 The candy war1 9037-The candy war (python, 파이썬) - 포인트: - 중복 확인은 set으로!!! - 사이클 배열 인덱스는 [ x % N ] 활용 가능 t = int(input()) for _ in range(t): n = int(input()) c = list(map(int, input().split())) d = [0] * n circuit_count = 0 while True: for x in range(n): if c[x] % 2: c[x] = c[x] + 1 d[x] = c[x] // 2 if len(set(c)) == 1: print(circuit_count) break for x in range(1, n): c[x] = c[x] // 2 + d[x-1] c[0] = c[0] // 2 + d[-1] circuit_count += 1 2020. 10. 15. 이전 1 다음