답안 #1019650

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1019650 2024-07-11T06:33:37 Z Minbaev 홀-짝 수열 (IZhO11_oddeven) PyPy
0 / 100
22 ms 19272 KB
def binpow(a, b):
  if b == 0:
    return 1
  if b % 2 == 0:
    c = binpow(a, b // 2)
    return (c * c) % mod
  return (binpow(a, b - 1) * a) % mod

def divi(a, b):
  return (a * binpow(b, mod - 2)) % mod

mod = 1e9 + 7

def solve():
  n = int(input())

  l = 1
  r = 1e9
  ans = -1
  while l <= r:
    mid = (l + r) // 2

    sum = mid * (mid + 1) // 2
    if sum >= n:
      ans = mid
      r = mid - 1
    else:
      l = mid + 1

  # Correct calculation for 'val'
  val = (ans * (ans + 1) // 2 - n) * 2 + (ans - 1)

  print(val)

if __name__ == "__main__":
  tt = 1  # Change this to int(input()) for multiple test cases
  while tt:
    solve()
    tt -= 1
# 결과 실행 시간 메모리 Grader output
1 Incorrect 22 ms 19272 KB Output isn't correct
2 Halted 0 ms 0 KB -