招行信用卡笔试,编程题求解答
1.输出是否为回文字符串,1-》1,2—》5,3-》8.。。。
#招商银行信用卡中心2020春招##招商银行信用卡中心##笔试题目#
import sys
if __name__ == "__main__":
n = int(sys.stdin.readline().strip())
dict = {'1': '1', '2': '5', '3': '8', '4': '7', '6': '9'}
for i in range(n):
read = sys.stdin.readline().strip()
i = 0
j = len(read) - 1
while (i < j):
if dict[read[i]] == read[j]:
i += 1
j -= 1
else:
break
if i >= j:
print('YES')
else:
print('NO') 通过0%。。。
2.输入n
输入n行------数字串 k
判断数字串通过几种加减操作==k
import sys if __name__ == "__main__": # 读取第一行的n n = int(sys.stdin.readline().strip()) for i in range(n): # 读取每一行 result = [] line = sys.stdin.readline().strip() values,k = line.split() k = int(k) values = list(map(int,list(values))) result.append(values.pop(0)) while(len(values)!=0): temp = values.pop(0) # print(values) re = result[:] for i,num in enumerate(result): numa = num+temp numb = num-temp re.append(numa) re.append(numb) del re[i] result = re[:] count = 0 for i in result: if i==k: count += 1 print(count)
#招商银行信用卡中心2020春招##招商银行信用卡中心##笔试题目#

