[伯俊]1296チームの名前付け
984 ワード
質問する
に答える
コード#コード# import sys
def solution() :
y = sys.stdin.readline().rstrip()
n = int(sys.stdin.readline())
std = list('LOVE')
if n == 1 :
print(sys.stdin.readline().rstrip())
else :
res = []
for _ in range(n) :
s = sys.stdin.readline().rstrip()
calc = 1
for i in range(len(std)) :
for j in range(i+1, len(std)) :
calc *= (y.count(std[i]) + s.count(std[i])) + (y.count(std[j]) + s.count(std[j]))
res.append((calc % 100, s))
res.sort(key = lambda x : (-x[0], x[1]))
print(res[0][1])
solution()
Reference
この問題について([伯俊]1296チームの名前付け), 我々は、より多くの情報をここで見つけました
https://velog.io/@tldjfj123/백준-1296.-팀-이름-정하기
テキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol
import sys
def solution() :
y = sys.stdin.readline().rstrip()
n = int(sys.stdin.readline())
std = list('LOVE')
if n == 1 :
print(sys.stdin.readline().rstrip())
else :
res = []
for _ in range(n) :
s = sys.stdin.readline().rstrip()
calc = 1
for i in range(len(std)) :
for j in range(i+1, len(std)) :
calc *= (y.count(std[i]) + s.count(std[i])) + (y.count(std[j]) + s.count(std[j]))
res.append((calc % 100, s))
res.sort(key = lambda x : (-x[0], x[1]))
print(res[0][1])
solution()
Reference
この問題について([伯俊]1296チームの名前付け), 我々は、より多くの情報をここで見つけました https://velog.io/@tldjfj123/백준-1296.-팀-이름-정하기テキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol