牛客网在线编程(Python3)

彩色的砖块

def get_s():
    s=input("S:")
    len_s=len(list(set(s)))
    if len_s>2:
        return 0
    else:
        return len_s
print(get_s())

等差数列

def judge(s):
    sort_list = sorted(s)
    d=sort_list[1]-sort_list[0]
    for i in range(len-1):
        if sort_list[i+1]-sort_list[i]!=d:
            return "Impossible"
    return "Possible"
len=int(input("Length"))
s=[]
for i in range(len):
    s.append(int(input("")))
print(judge(s))

交错01串

s=input("")
def Length_ZC(s):
    len_s=len(s)
    max_list=[]
    max_len=0
    for i in range(len_s-1):
        if s[i+1]!=s[i]:
            max_list.append(s[i])
        else:
            if len(max_list)+1>max_len:
                max_len=len(max_list)+1
            max_list=[]
    if len(max_list)+1>max_len:
        max_len=len(max_list)+1
    return max_len
print(Length_ZC(s))

独立的小易

‘//’:向下取整

x,f,d,p = map(int,input("").split(" "))
if d/x < f:
    print(d//x)
else:
    print((d+f*p)//(x+p))

你可能感兴趣的:(牛客网在线编程(Python3))