python 代码festa样本

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python 代码festa样本相关的知识,希望对你有一定的参考价值。

#-*- coding: utf-8 -*-
# serve-t-shirts.py

# handle inputs
T = int(raw_input())

x, y = [], []
for i in xrange(T):
    x.append(raw_input())
    y.append(raw_input())


# process
for xi, yi in zip(x, y):
    n_tshirts = [xi.count('S'), xi.count('M'), xi.count('L')]
    n_people = [yi.count('S'), yi.count('M'), yi.count('L')]

    # check for L people
    if n_tshirts[2] < n_people[1]:
        print 'NO'
        continue
    n_tshirts[2] -= n_people[2]
    n_people[2] = 0

    # check for M people
    # first M people put on L T-shirt
    n_people[1] -= n_tshirts[2]
    n_tshirts[2] = 0
    if n_tshirts[1] < n_people[1]:
        print 'NO'
        continue
    n_tshirts[1] -= n_people[1]
    n_people[1] = 0

    # check for S people
    n_people[0] -= n_tshirts[1]
    n_tshirts[1] = 0
    if n_tshirts[0] < n_people[0]:
        print 'NO'
        continue
    n_tshirts[0] -= n_people[0]
    n_people[0] = 0

    print 'YES'

#-*- coding: utf-8 -*-

T = int(raw_input())

N = []
for i in xrange(T):
    N.append(int(raw_input()))


for N_i in N:
    count = 0
    while N_i != 1:
        if N_i % 2 == 0:
            N_i /= 2
        else:
            N_i = N_i * 3 + 1
        count += 1
    print count
#-*- coding: utf-8 -*-
# binary-tape.py

# handle inputs
T = int(raw_input())

N, S = [], []
for i in xrange(T):
    N.append(int(raw_input()))
    S.append(raw_input())

# process
for N_i, S_i in zip(N, S):
    count = 0
    start = 0
    end = 1
    while end <= len(S_i):
        if int(S_i[start:end], 2) >= N_i:
            count += 1
            start = end
            end = start + 1
        else:
            end += 1
    print count

以上是关于python 代码festa样本的主要内容,如果未能解决你的问题,请参考以下文章

K-means 代码(python)

K-means 代码(python)

K-means 代码(python)

K-means 代码(python)

发现样本数量不一致的输入变量:Python 中的 [23038, 7680]

Python笔记-假设检验之双样本T检验(两样本是否相似)