# Python【2021蓝桥杯省赛编程题】

## Python【2021蓝桥杯省赛编程题】

### F.时间显示

n = int(input()) // 1000 % 86400
h = n // 3600
m = n % 3600 // 60
s = n % 60
print(str("{:0>2d}".format(h)) + ":" + str("{:0>2d}".format(m)) + ":" + str("{:0>2d}".format(s)),end='')

### G.杨辉三角形

import math

n = int(input())

def C(mid,i):
ans = 1
for ii in range(1,i + 1):
ans *= (mid - ii + 1)
ans /= ii
if ans > n:
return ans
return ans

def check(i):
l, r, mid = 2 * i, max(n,2 * i), 0
while l < r:
mid = l + r >> 1
if C(mid,i) < n:
l = mid + 1
else:
r = mid
if C(l,i) == n:
print((l + 1) * l // 2 + i + 1,end='')
return True
return False

if n == 1:
print(1,end='')
else:
ii = 16
while ii > 0:
if check(ii):
break
ii-=1

### H.左孩子右兄弟

n = int(input())
# 建树
tree = [[] for i in range(0,n + 5)]
for i in range(2,n + 1):
tree[int(input())].append(i)

def dfs(now):
mn = 0
for i in tree[now]:
mn = max(mn,dfs(i))
return mn + len(tree[now])
print(dfs(1))

n = int(input())
f = [0 for i in range(n + 5)]
c = [0 for i in range(n + 5)]
dp = [0 for i in range(n + 5)]
for i in range(2,n + 1):
x = int(input())
f[i] = x
c[x] += 1
for i in range(n, 0, -1):
dp[f[i]] = max(dp[f[i]],dp[i] + c[f[i]])
print(dp[1])

### I.异或数列

t = int(input())
for _ in range(0,t):
x = list(map(int,input().split()))
y = [0 for i in range(25)]
# 将每个数都分离成二进制
for i in range(1,len(x)):
now = 0
while x[i] > 0:
y[now] += x[i] % 2
x[i] //= 2
now += 1
# 判断胜负
i = 20
flag = 1
while i >= 0:
if y[i] % 2 == 0:
i -= 1
continue
else:
if y[i] == 1:
print('1')
flag = 0
break
if x[0] % 2 == 1:
print('1')
flag = 0
break
else:
print('-1')
flag = 0
break
if flag == 1:
print('0')

THE END

)">