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='')
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
啊这,这个题用python自带的组合数竟然过不了。。。。。。。。。
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))
这个用dfs不知道为啥ACwing老是报RE。
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])
这个不用递归就能过。。。
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')
之后更。。。