The Captain's Room

  • + 1 comment

    Input group size

    n = int(input())

    Input the list of room numbers

    x = list(map(int, input().split()))

    Use a set to extract unique room numbers

    unique_rooms = set(x)

    Use the mathematical approach to calculate the Captain's room

    captain_room = (sum(unique_rooms) * n - sum(x)) // (n - 1)

    Output the Captain's

    print(captain_room)

    This is the best answer