腾讯笔试 100 100 0 100 90
最大数,滑动数组,第三题忘了,第四题进制转换,第五题取名字
第二题滑动数组做过100遍还是花了我一个小时,第三题根本没时间去看了
# 腾讯第一题,最大数
n,m = map(int, input().split())
lsa = list(map(int,input().split()))
lsb = list(map(int,input().split()))
lsa.sort()
lsb.sort()
if max(lsa[:-1]) <=0 and min(lsb)>=0:
print(lsa[-2]*lsb[0])
elif min(lsa[1:]) >=0 and max(lsb)<=0:
print(lsa[1]*lsb[-1])
elif lsa[-1]*lsb[-1] > lsa[0]*lsb[0]:
print(max(lsa[-2]*lsb[-1],lsa[0]*lsb[0]))
else:
print(max(lsa[-1]*lsb[-1],lsa[1]*lsb[0]))
# 腾讯第二题,区间数
while True:
try:
n = int(input())
ls = list(abs(i) for i in map(int, input().split()))
ls.sort()
count = 0
left = 0
right = 0
while left < n-1:
while right <n:
if ls[left]*2 >= ls[right]:
right += 1
else:
break
count += max(0,right-left -1)
left += 1
print(count)
except:
break
# 腾讯笔试第四题 进制转换
def helper(num):
if num < 10:
return num
elif num >= 10:
return chr(num - 10 + 65)
def k2ten(k, number):
return int(str(number), base=k)
def ten2k(k, number):
ls = []
while True:
s = number // k
tmp = number % k
ls.append(helper(tmp))
if s == 0:
break
number = s
ls = [str(i) for i in ls[::-1]]
return (''.join(ls))
while True:
try:
t = int(input())
ans_list = []
for _ in range(t):
k = int(input())
num1,num2,cha = input().split()
num1_new = k2ten(k,str(num1))
num2_new = k2ten(k,str(num2))
ans = eval(str(num1_new) + cha + str(num2_new))
res = ten2k(k,ans)
ans_list.append(res)
for item in ans_list:
print(item)
except:
break
# 腾讯第五题, AC 0.9
n,m = map(int, input().split())
ls = []
for _ in range(n):
ls.append(input())
ls.sort()
ans_ls = [-1] * m
for i in range(m):
str1,str2 = input().split()
len1, len2 = len(str1), len(str2)
for item in ls:
if item[:len1] == str1 and item[:len2] != str2:
ans_ls[i] = item
ls.remove(item)
break
print(ans_ls)
忽略时有时无的while true。。。。测试的时候一度以为是没有加while True导致AC不了, 后来发现是想多了
#腾讯##笔试题目##秋招#