20190927网易

网易

1.

n=int(input().strip())
zong=[0 for i in range(10)]
fen=[0 for i in range(10)]
def jishu(shu):
    global fen
    while shu!=0 :
        s=shu%10
        fen[s]+=1
        shu=shu//10
for j in range(n):
    shua,shub=map(int,input().strip().split())
    fen=[0 for i in range(10)]
    jishu(shua)
    jishu(shub)
    tempb=shub
    res=0
    base=1
    while tempb!=0:
        s=tempb%10
        tempres=s*shua
        jishu(tempres)
        res=res+tempres*base
        tempb=tempb//10
        base=base*10
    jishu(res)
    for i in range(1,10):
        zong[i]+=fen[i]
        if i!=9:
            print(fen[i],end=' ')
        else:
            print(fen[i])
maxn=-1
shu=1
for i in range(1,10):
    if zong[i]>maxn:
        maxn=zong[i]
        shu=i
    #print(zong[i])
print(shu)

2.

from itertools import permutations
t = int(input().strip())
for _ in range(t):
	s = input().strip()
	d = {}
	ans = float('inf')
	for t0, t1, t2, t3, t4, t5 in permutations('ASDFGH', 6):
		d[t0], d[t1], d[t2], d[t3], d[t4], d[t5] = 0, 1, 2, 3, 4, 5
		res = abs(d[s[0]])
		for i in range(1, len(s)):
			res += abs(d[s[i]] - d[s[i-1]])
		ans = min(res, ans)
	print(ans if ans != float('inf') else 0)

3.

太难了吧。。。

猜你喜欢

转载自blog.csdn.net/LXQ1071717521/article/details/101997381