This commit is contained in:
BarsTiger
2021-10-15 12:46:53 +03:00
parent b9772007b3
commit 68fb5410ee
45 changed files with 729 additions and 16 deletions

View File

@@ -0,0 +1,12 @@
tortiv, kmonet = map(int, input().split())
uzeEst = kmonet + 1
if kmonet > tortiv:
potratil = tortiv - 1
else:
potratil = kmonet
if uzeEst < tortiv:
potratil += (tortiv - uzeEst)
print(potratil)

View File

@@ -0,0 +1,21 @@
chisloVV = int(input())
deystviy = 0
while chisloVV != 1:
if chisloVV % 3 == 0:
chisloVV = chisloVV / 3
deystviy += 1
elif (chisloVV + 1) % 3 == 0:
chisloVV = (chisloVV + 1) / 3
deystviy += 2
elif (chisloVV - 1) % 3 == 0:
chisloVV = (chisloVV - 1) / 3
deystviy += 2
else:
chisloVV = chisloVV - 1
deystviy += 1
print(deystviy)

View File

@@ -0,0 +1,20 @@
dlina = int(input())
massiv = input().split()
deystviy = 0
for i in range(dlina):
tempDeyst = 0
idlapoiskaed = 0
for kjkjjljdfg in range(dlina):
if massiv[idlapoiskaed] == '1':
break
idlapoiskaed += 1
if massiv[i] == "0":
for j in range(i):
if massiv[j] == "1":
tempDeyst += 1
deystviy += tempDeyst
massiv[i], massiv[idlapoiskaed] = massiv[idlapoiskaed], massiv[i]
print(deystviy)

View File

@@ -0,0 +1,39 @@
string = input()
podxodat = 0
def gen_all_pidradki():
allPidradkii = set()
for i in range(len(string)):
for j in range(len(string), i, -1):
allPidradkii.add(string[i:j:1])
return allPidradkii
def gen_all_pidradki_2(txt, start):
allPidradkii = []
while start <= len(txt):
for i in range(0, len(txt)):
if i <= len(txt) - start:
allPidradkii.append(txt[i:i + start])
start = start + 1
return allPidradkii
allPidradki = gen_all_pidradki_2(string, 3)
for i in allPidradki:
odinak = 0
maxOdinak = 0
for j in range(len(i)):
odinak = 0
for sravn in range(len(i)):
if i[j] == i[sravn]:
odinak += 1
if odinak > maxOdinak:
maxOdinak = odinak
if maxOdinak == (len(i) - 1):
podxodat += 1
print(podxodat)

View File

@@ -0,0 +1,17 @@
a, b, c = input().split()
a = int(a)
b = int(b)
c = int(c)
exist = "No"
if a + b == c:
exist = "Yes"
if a + c == b:
exist = "Yes"
if c + b == a:
exist = "Yes"
print(exist)

View File

@@ -0,0 +1,46 @@
import itertools
dovzina = int(input())
vsechisla = []
allpairs = []
praviln = 0
def gen_all_numbers():
for i in itertools.product(['1', '2', '3', '4', '5', '6', '7', '8', '9', '0'], repeat=dovzina):
chislo = ''.join(i)
if chislo[0] != "0":
vsechisla.append(int(chislo))
def get_all_pairs():
allpairsgen = []
allpairsgen.append(itertools.combinations(vsechisla, 2))
for tup in allpairsgen:
for item in tup:
allpairs.append(item)
def vozak_kus(num1, num2):
res = ""
res_in_list = []
for kakoeplusovat in range(1, dovzina + 1):
strnum1 = str(num1)
strnum2 = str(num2)
polures = str(int(strnum1[-kakoeplusovat]) + int(strnum2[-kakoeplusovat]))
if len(polures) >= 2:
polures = polures[-1]
res_in_list.insert(0, ((int(polures))))
for i in range(len(res_in_list)):
res = res + str(res_in_list[i])
return int(res)
def standart_plus(num1, num2):
return num1 + num2
gen_all_numbers()
get_all_pairs()
for i in allpairs:
if vozak_kus(i[0], i[1]) == standart_plus(i[0], i[1]):
praviln += 1
print(int("1" + "0" + "0" * dovzina) + praviln)

View File

@@ -0,0 +1,18 @@
kolvo = int(input())
ludi = input().split()
devochek = 0
malchikov = 0
for i in ludi:
if i == "1":
malchikov += 1
elif i == "2":
devochek += 1
if malchikov < devochek:
print(malchikov)
else:
print(devochek)

View File

@@ -0,0 +1,22 @@
a, b = input().split()
c, d = input().split()
a = int(a)
b = int(b)
c = int(c)
d = int(d)
peremig = "T"
if a + d > c + b:
peremig = "U"
elif a + d < c + b:
peremig = "P"
elif a + d == c + b:
if d > b:
peremig = "U"
elif d < b:
d > b
print(peremig)

View File

@@ -0,0 +1,4 @@
kolvo = int(input())
giroda = set(map(int, input().split()))
print((max(giroda) - min(giroda)) * 2)

View File

@@ -0,0 +1,13 @@
p, m, o = input().split()
p = int(p)
m = int(m)
o = int(o)
if p > m and p > o:
print("Petryk")
elif m > p and m > o:
print("Marichka")
elif o > p and o > m:
print("Olenka")

View File

@@ -0,0 +1,5 @@
x1, y1, x2, y2 = map(int, input().split())
if x1 < x2:
print(x1, y2, x2, y1)
else:
print(x2, y1, x1, y2)

View File

@@ -0,0 +1,25 @@
koordvvod = input()
bukva = koordvvod[0]
tsifra = int(koordvvod[1])
atoone = {"A": 1, "B": 2, "C": 3, "D": 4, "E": 5, "F": 6, "G": 7, "H": 8}
koord1 = atoone[bukva]
koord2 = tsifra
tsvet = ""
if koord1/2 != koord1//2 and koord2/2 != koord2//2:
tsvet = "BLACK"
elif koord1/2 != koord1//2 and koord2/2 == koord2//2:
tsvet = "WHITE"
elif koord1/2 == koord1//2 and koord2/2 != koord2//2:
tsvet = "WHITE"
elif koord1/2 == koord1//2 and koord2/2 == koord2//2:
tsvet = "BLACK"
print(tsvet)

View File

@@ -0,0 +1,6 @@
dlina = int(input())
vse_parametry = input().split()
vse_parametry.append(dlina)
vse_parametry = set(map(int, vse_parametry))
print(max(vse_parametry))

View File

@@ -0,0 +1,34 @@
kilkist = int(input())
kolo = input().split()
x = 0
canornot = "No"
perviposl = [kolo[0], kolo[-1]]
for i in range(kilkist):
if i == kilkist:
i = 0
iplusodin = i + 1
iplusdwa = i + 2
if iplusdwa >= kilkist - 1:
iplusdwa = iplusdwa - (kilkist - 1)
if iplusodin >= kilkist - 1:
iplusodin = iplusodin - (kilkist - 1)
if kolo[i] == kolo[iplusodin] and kolo[i] == kolo[iplusdwa]:
canornot = "Yes"
print(canornot)
exit()
if kolo[i] == kolo[iplusodin]:
x = kolo[i]
for j in range(i + 1, kilkist):
if j == kilkist:
j = 0
jplusodin = j + 1
if jplusodin >= kilkist - 1:
jplusodin = jplusodin - kilkist
if kolo[j] == x and kolo[jplusodin] == x:
canornot = "Yes"
print(canornot)
exit()
print(canornot)