9.23 360测试笔试
(回忆版
选择题
二十多道
某C程序运行结果
条件覆盖
(剩下忘了)
……
解答题
测试理论题(十五道左右):
bug的生命周期
软件缺陷的等级划分
测出来bug,开发说不是,怎么做?
测试要有什么素质,如何做好测试
测试覆盖的方法有哪些?
写5个网络协议
测试用例的组成部分
GET、POST区别
无线路由器的测试
……
一道智力推理题
一道编程题
公司有n个员工,每个员工有相应的能力值(正整数),一个项目需要[n / 2]个员工,而选中的员工总能力值也需要大于等于该项目所需能力值。
输入格式:
先输入T,表示T组数据;
每组有两行数据:第一行为n, x,分别表示公司员工数量,项目所需能力值;第二行中ai,表示第i个员工的能力值。
输出格式:
输出T行,每行输出该组数据中能实现项目要求的组合数。
输入用例:
3
5 10
3 2 3 4 5
3 3
1 1 1
10 10
3 1 2 8 5 4 2 9 12 7
输出:
7
0
252
import itertools, math
def count_combinations(a, num, x):
count = 0
combinations = itertools.combinations(a, num)
for comb in combinations:
if sum(comb) >= x:
count += 1
return count
T = int(input())
for _ in range(T):
n, x = list(map(int, input().split()))
a = list(map(int, input().split()))
num = math.ceil(n / 2)
result = count_combinations(a, num, x)
print(result)
import math
def count_combinations(a, num, x):
count = [0]
backtrack(a, num, x, 0, 0, count)
return count[0]
def backtrack(a, num, x, start, cur_sum, count):
if num == 0:
# 如果取出了num个元素,判断当前和是否大于等于x
if cur_sum >= x:
count[0] += 1
return
for i in range(start, len(a)):
# 选择当前元素
cur_sum += a[i]
# 继续选择下一个元素
backtrack(a, num - 1, x, i + 1, cur_sum, count)
# 恢复状态
cur_sum -= a[i]
T = int(input())
for _ in range(T):
n, x = list(map(int, input().split()))
a = list(map(int, input().split()))
num = math.ceil(n / 2)
result = count_combinations(a, num, x)
print(result)
