哔哩哔哩笔试

1.

import sys

line=sys.stdin.readline().strip().split(" ")

for s in line:
    if len(s)%2!=0:
        print "".join(list(reversed(s))),
    else:
        print s,

2.

import sys

line=sys.stdin.readline().strip()

length=len(line)

if length==0 or line[0]=="0":
    print 0
else:
    res=[0]*(length+1)

    res[0]=1
    res[1]=1

    for i in range(2,length+1):
        if line[i-1]>="1" and line[i-1]<="9":
            res[i]+=res[i-1]
        if line[i-2]=="1" or line[i-2]=="2" and line[i-1]>=0 and line[i-1]<="6":
            res[i]+=res[i-2]

    print res[-1]

3.

import sys

def func(img,filter,hs,he,ws,we):
    tmp=0.0

    count_i=0
    count_j=0
    for i in range(hs,he):
        for j in range(ws,we):
            tmp+=img[i][j]*filter[count_i][count_j]
            count_j+=1
        count_j=0
        count_i+=1

    return int(tmp)

h, w = map(int, sys.stdin.readline().strip().split(" "))

img = []
for i in range(h):
    _ = map(int, sys.stdin.readline().strip().split(" "))
    img.append(_)

m = int(sys.stdin.readline().strip())

filter = []
for i in range(m):
    _ = map(float, sys.stdin.readline().strip().split(" "))
    filter.append(_)

new_h=h-m+1
new_w=w-m+1

res=[]
for i in range(new_h):
    _=[]
    for j in range(new_w):
        _.append( func(img,filter,i,i+m,j,j+m) )

    res.append(_)

for i in range(len(res)):
    for j in range(len(res[i])):
        print res[i][j],
    print

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值