1
This commit is contained in:
0
levieProekti/KOTIKOT programs/CATUID generator.py
Normal file
0
levieProekti/KOTIKOT programs/CATUID generator.py
Normal file
22
levieProekti/KOTIKOT programs/Catbench.py
Normal file
22
levieProekti/KOTIKOT programs/Catbench.py
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
input("To start benchmark, press enter...")
|
||||||
|
print("Testing your computer...")
|
||||||
|
|
||||||
|
import time
|
||||||
|
|
||||||
|
fromStartTest = time.time_ns()
|
||||||
|
|
||||||
|
n = 100000
|
||||||
|
def factorial(kolvo):
|
||||||
|
fakt = 1
|
||||||
|
for i in range(1, kolvo + 1):
|
||||||
|
fakt = fakt * i
|
||||||
|
return fakt
|
||||||
|
schislo = factorial(n)
|
||||||
|
|
||||||
|
|
||||||
|
timeForBench1 = time.time_ns() - fromStartTest
|
||||||
|
|
||||||
|
|
||||||
|
print("Time elapsed for bench 1 is " + str(timeForBench1/1000000000) + "s")
|
||||||
|
print("Now it is time for benchmark 2, results of all bench and mark of computer you will see later")
|
||||||
|
input("To exit CatBench press enter...")
|
||||||
4
levieProekti/KOTIKOT programs/printmeow.py
Normal file
4
levieProekti/KOTIKOT programs/printmeow.py
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
import time
|
||||||
|
time.sleep(1)
|
||||||
|
print("meow")
|
||||||
|
time.sleep(1)
|
||||||
21
levieProekti/Olymp2020/3MistaDoroga.py
Normal file
21
levieProekti/Olymp2020/3MistaDoroga.py
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
vvod = input("Введіть дані: ")
|
||||||
|
|
||||||
|
vidstan1 = vvod[0:3:1]
|
||||||
|
vidstan2 = vvod[4:7:1]
|
||||||
|
vidstan3 = vvod[8:11:1]
|
||||||
|
|
||||||
|
if vidstan1 == " " or vidstan2 == " " or vidstan3 == " ":
|
||||||
|
print("no")
|
||||||
|
|
||||||
|
elif vidstan1 == vidstan2 or vidstan1 == vidstan3 or vidstan2 == vidstan3:
|
||||||
|
print(0)
|
||||||
|
|
||||||
|
elif vidstan2 < vidstan3:
|
||||||
|
print(1)
|
||||||
|
|
||||||
|
elif vidstan2 > vidstan3:
|
||||||
|
print(2)
|
||||||
|
|
||||||
|
elif vidstan1 > vidstan2:
|
||||||
|
print(3)
|
||||||
|
|
||||||
18
levieProekti/Olymp2020/IschoOdnaOlymp2020/Detour.py
Normal file
18
levieProekti/Olymp2020/IschoOdnaOlymp2020/Detour.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
n, m = input().split()
|
||||||
|
n = int(n)
|
||||||
|
m = int(m)
|
||||||
|
|
||||||
|
povoroti = 0
|
||||||
|
|
||||||
|
while n > 0 and m > 0:
|
||||||
|
if n == 2:
|
||||||
|
povoroti = povoroti + 2
|
||||||
|
elif n > 2 and m > 2:
|
||||||
|
povoroti = povoroti + 4
|
||||||
|
elif m == 2:
|
||||||
|
povoroti = povoroti + 3
|
||||||
|
|
||||||
|
n = n - 2
|
||||||
|
m = m - 2
|
||||||
|
|
||||||
|
print(povoroti)
|
||||||
23
levieProekti/Olymp2020/IschoOdnaOlymp2020/Mult2020.py
Normal file
23
levieProekti/Olymp2020/IschoOdnaOlymp2020/Mult2020.py
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
iznchislo, kolvopodelit = input().split()
|
||||||
|
iznchislo = int(iznchislo)
|
||||||
|
kolvopodelit = int(kolvopodelit)
|
||||||
|
chislo = iznchislo
|
||||||
|
summaitely = []
|
||||||
|
maxinsummately = 0
|
||||||
|
|
||||||
|
if iznchislo == kolvopodelit:
|
||||||
|
for i in range(kolvopodelit):
|
||||||
|
summaitely.append(1)
|
||||||
|
|
||||||
|
else:
|
||||||
|
for yey in range(kolvopodelit):
|
||||||
|
chislo = chislo // 2 + chislo % 2
|
||||||
|
summaitely.append(chislo)
|
||||||
|
if chislo == 0:
|
||||||
|
if yey == 0:
|
||||||
|
maxinsummately = chislo
|
||||||
|
summaitely.append(maxinsummately - 1)
|
||||||
|
summaitely.remove(maxinsummately)
|
||||||
|
maxinsummately = maxinsummately - 1
|
||||||
|
|
||||||
|
print(summaitely)
|
||||||
8
levieProekti/Olymp2020/IschoOdnaOlymp2020/Pillars.py
Normal file
8
levieProekti/Olymp2020/IschoOdnaOlymp2020/Pillars.py
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
n, m = input().split()
|
||||||
|
n = int(n)
|
||||||
|
m = int(m)
|
||||||
|
sposobi = 0
|
||||||
|
|
||||||
|
if n / 2 != n % 2:
|
||||||
|
sposobi = 1
|
||||||
|
|
||||||
9
levieProekti/Olymp2020/MANolymp19_11_2020/meandr.py
Normal file
9
levieProekti/Olymp2020/MANolymp19_11_2020/meandr.py
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
a, n = input().split()
|
||||||
|
a = int(a)
|
||||||
|
n = int(n)
|
||||||
|
x = 0
|
||||||
|
y = 0
|
||||||
|
tochkaVsego = 0
|
||||||
|
|
||||||
|
# for linia in range(n + 1):
|
||||||
|
# for tochka in range(a + 1):
|
||||||
48
levieProekti/Olymp2020/MANolymp19_11_2020/monarch.py
Normal file
48
levieProekti/Olymp2020/MANolymp19_11_2020/monarch.py
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
n = int(input())
|
||||||
|
vseCheliki = []
|
||||||
|
|
||||||
|
for chelovek in range(1, n + 1):
|
||||||
|
vseCheliki.append(chelovek)
|
||||||
|
|
||||||
|
sposobi = 0
|
||||||
|
|
||||||
|
while len(vseCheliki) > 3:
|
||||||
|
dlinaChelikov = len(vseCheliki) + 1
|
||||||
|
for i in range(dlinaChelikov):
|
||||||
|
if i < len(vseCheliki):
|
||||||
|
if vseCheliki[i]//2 == vseCheliki[i]/2:
|
||||||
|
vseCheliki[i] = 0
|
||||||
|
|
||||||
|
scetchik = 0
|
||||||
|
while 0 in vseCheliki:
|
||||||
|
vseCheliki.remove(0)
|
||||||
|
dlinaChelikov = len(vseCheliki) + 1
|
||||||
|
vseCheliki.clear()
|
||||||
|
|
||||||
|
for chelovek in range(1, dlinaChelikov):
|
||||||
|
vseCheliki.append(chelovek)
|
||||||
|
|
||||||
|
sposobi = sposobi + 1
|
||||||
|
|
||||||
|
for chelovek in range(1, n + 1):
|
||||||
|
vseCheliki.append(chelovek)
|
||||||
|
|
||||||
|
while len(vseCheliki) > 3:
|
||||||
|
dlinaChelikov = len(vseCheliki) + 1
|
||||||
|
for i in range(dlinaChelikov):
|
||||||
|
if i < len(vseCheliki):
|
||||||
|
if vseCheliki[i]//2 != vseCheliki[i]/2:
|
||||||
|
vseCheliki[i] = 0
|
||||||
|
|
||||||
|
scetchik = 0
|
||||||
|
while 0 in vseCheliki:
|
||||||
|
vseCheliki.remove(0)
|
||||||
|
dlinaChelikov = len(vseCheliki) + 1
|
||||||
|
vseCheliki.clear()
|
||||||
|
|
||||||
|
for chelovek in range(1, dlinaChelikov):
|
||||||
|
vseCheliki.append(chelovek)
|
||||||
|
|
||||||
|
sposobi = sposobi + 1
|
||||||
|
|
||||||
|
print(sposobi)
|
||||||
16
levieProekti/Olymp2020/PyOlymp2020Kakaato/MagichnaFunkcia.py
Normal file
16
levieProekti/Olymp2020/PyOlymp2020Kakaato/MagichnaFunkcia.py
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
dlina = int(input())
|
||||||
|
a = input().split()
|
||||||
|
b = input().split()
|
||||||
|
max = 0
|
||||||
|
|
||||||
|
for i in range(dlina):
|
||||||
|
for j in range(i + 1):
|
||||||
|
if i == j:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
resultit = int(a[i]) * int(b[j]) + int(a[j]) * int(b[i])
|
||||||
|
if resultit > max:
|
||||||
|
max = resultit
|
||||||
|
|
||||||
|
|
||||||
|
print(max)
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
a, b = map(int, input().split())
|
||||||
|
print(a + b)
|
||||||
23
levieProekti/Olymp2020/PyOlymp2020Kakaato/Testuvanna.py
Normal file
23
levieProekti/Olymp2020/PyOlymp2020Kakaato/Testuvanna.py
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
dlina = int(input())
|
||||||
|
chisla = input().split()
|
||||||
|
parnie = []
|
||||||
|
neparnie = []
|
||||||
|
|
||||||
|
for i in range(dlina):
|
||||||
|
if int(chisla[i]) // 2 == int(chisla[i]) / 2:
|
||||||
|
parnie.append(int(chisla[i]))
|
||||||
|
|
||||||
|
else:
|
||||||
|
neparnie.append(int(chisla[i]))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if len(parnie) > len(neparnie):
|
||||||
|
for u in range(dlina):
|
||||||
|
if int(chisla[u]) in neparnie:
|
||||||
|
print(u + 1)
|
||||||
|
|
||||||
|
else:
|
||||||
|
for u in range(dlina):
|
||||||
|
if int(chisla[u]) in parnie:
|
||||||
|
print(u + 1)
|
||||||
27
levieProekti/Olymp2020/PyOlymp2020Kakaato/abloki.py
Normal file
27
levieProekti/Olymp2020/PyOlymp2020Kakaato/abloki.py
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
n, m, k = input().split()
|
||||||
|
n = int(n)
|
||||||
|
m = int(m)
|
||||||
|
k = int(k)
|
||||||
|
dovolnie = 0
|
||||||
|
|
||||||
|
while n > 0 or m > 0 or k > 0:
|
||||||
|
if n > 0 and m > 0:
|
||||||
|
dovolnie = dovolnie + 1
|
||||||
|
n = n - 1
|
||||||
|
m = m - 1
|
||||||
|
|
||||||
|
elif n > 0 and k > 0:
|
||||||
|
dovolnie = dovolnie + 1
|
||||||
|
n = n - 1
|
||||||
|
k = k - 1
|
||||||
|
|
||||||
|
elif m > 0 and k > 0:
|
||||||
|
dovolnie = dovolnie + 1
|
||||||
|
m = m - 1
|
||||||
|
k = k - 1
|
||||||
|
|
||||||
|
else:
|
||||||
|
break
|
||||||
|
|
||||||
|
|
||||||
|
print(dovolnie)
|
||||||
32
levieProekti/Olymp2020/PyOlymp2020Kakaato/abloki2.py
Normal file
32
levieProekti/Olymp2020/PyOlymp2020Kakaato/abloki2.py
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
n, m, k = input().split()
|
||||||
|
n = int(n)
|
||||||
|
m = int(m)
|
||||||
|
k = int(k)
|
||||||
|
|
||||||
|
chisla = [n, m, k]
|
||||||
|
|
||||||
|
maxOfAll = max(chisla)
|
||||||
|
minOfAll = min(chisla)
|
||||||
|
|
||||||
|
maxandmin = [maxOfAll, minOfAll]
|
||||||
|
srednee = 0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
for a in range(3):
|
||||||
|
if chisla[a] not in maxandmin:
|
||||||
|
srednee = chisla[a]
|
||||||
|
|
||||||
|
if srednee == 0:
|
||||||
|
srednee = minOfAll
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
dovolnie = minOfAll
|
||||||
|
if minOfAll == 0:
|
||||||
|
minOfAll = srednee
|
||||||
|
else:
|
||||||
|
dovolnieList = [maxOfAll - minOfAll, srednee]
|
||||||
|
dovolnie = dovolnie + min(dovolnieList)
|
||||||
|
|
||||||
|
print(dovolnie)
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
mesats, den, denNedeliVvod = input().split()
|
||||||
|
mesats = int(mesats)
|
||||||
|
den = int(den)
|
||||||
|
denNedeliVvod = int(denNedeliVvod)
|
||||||
|
mesatsNado, denNado = input().split()
|
||||||
|
mesatsNado = int(mesatsNado)
|
||||||
|
denNado = int(denNado)
|
||||||
|
vseMesatsiVGodu = {1:31, 2:28, 3:31, 4:30, 5:31, 6:30, 7:31, 8:31, 9:30, 10:31, 11:30, 12:31}
|
||||||
|
dneyDoMesats = 0
|
||||||
|
dneyDoMesatsNado = 0
|
||||||
|
for uiu in range(1, mesats):
|
||||||
|
dneyDoMesats = dneyDoMesats + vseMesatsiVGodu[uiu]
|
||||||
|
dneyDoMesats = dneyDoMesats + den
|
||||||
|
|
||||||
|
for uiu in range(1, mesatsNado):
|
||||||
|
dneyDoMesatsNado = dneyDoMesatsNado + vseMesatsiVGodu[uiu]
|
||||||
|
dneyDoMesatsNado = dneyDoMesatsNado + denNado
|
||||||
|
|
||||||
|
|
||||||
|
raznitsaMeshduNadoIBilo = dneyDoMesatsNado - dneyDoMesats
|
||||||
|
raznitsaMeshduNadoIBilo = abs(raznitsaMeshduNadoIBilo)
|
||||||
|
|
||||||
|
otvet = (raznitsaMeshduNadoIBilo - denNedeliVvod) % 7
|
||||||
|
|
||||||
|
if otvet == 0:
|
||||||
|
print(otvet + 1)
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
a = int(input())
|
||||||
|
b = input().split()
|
||||||
|
sum = 0
|
||||||
|
for c in b:
|
||||||
|
sum += int(c)
|
||||||
|
print(sum)
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
a = int(input())
|
||||||
|
print(a * a)
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
input()
|
||||||
|
print(25)
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
year = input()
|
||||||
|
|
||||||
|
stoletie = 0
|
||||||
|
|
||||||
|
if int(year)/100 < 1:
|
||||||
|
stoletie = 1
|
||||||
|
|
||||||
|
elif int(year)/100 == int(year)//100:
|
||||||
|
stoletie = int(year)/100
|
||||||
|
|
||||||
|
else:
|
||||||
|
stoletie = int(year)//100 + 1
|
||||||
|
|
||||||
|
|
||||||
|
print(int(stoletie))
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
vvod = input()
|
||||||
|
chisla = []
|
||||||
|
res = ""
|
||||||
|
|
||||||
|
for i in vvod:
|
||||||
|
if i.isdigit():
|
||||||
|
chisla.append(i)
|
||||||
|
|
||||||
|
for i in range(1, 10):
|
||||||
|
if str(i) not in chisla:
|
||||||
|
res = res + str(i)
|
||||||
|
|
||||||
|
if len(res) == 0:
|
||||||
|
res = "0"
|
||||||
|
|
||||||
|
print(int(res))
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
tsena, moneta1, moneta2 = input().split()
|
||||||
|
tsena = int(tsena)
|
||||||
|
moneta1 = int(moneta1)
|
||||||
|
moneta2 = int(moneta2)
|
||||||
|
sposobi = 0
|
||||||
|
kolvo1 = 0
|
||||||
|
kolvo2 = 0
|
||||||
|
|
||||||
|
while moneta1 * kolvo1 <= tsena and moneta1 * kolvo1 + moneta2 * kolvo2 <= tsena:
|
||||||
|
while moneta2 * kolvo2 <= tsena and moneta1 * kolvo1 + moneta2 * kolvo2 <= tsena:
|
||||||
|
if moneta1 * kolvo1 + moneta2 * kolvo2 == tsena:
|
||||||
|
sposobi = sposobi + 1
|
||||||
|
kolvo2 = kolvo2 + 1
|
||||||
|
kolvo1 = kolvo1 + 1
|
||||||
|
kolvo2 = 0
|
||||||
|
|
||||||
|
print(sposobi)
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
tsena, moneta1, moneta2 = input().split()
|
||||||
|
tsena = int(tsena)
|
||||||
|
moneta1 = int(moneta1)
|
||||||
|
moneta2 = int(moneta2)
|
||||||
|
sposobi = 0
|
||||||
|
kolvo1 = 0
|
||||||
|
kolvo2 = 0
|
||||||
|
coins = [moneta1, moneta2]
|
||||||
|
|
||||||
|
def countChange(money, coins):
|
||||||
|
if money == 0:
|
||||||
|
return 1
|
||||||
|
elif money < 0 or len(coins) == 0:
|
||||||
|
return 0
|
||||||
|
else:
|
||||||
|
return money, [coins[1]] + countChange(money - coins[0], coins)
|
||||||
|
|
||||||
|
print(countChange(tsena, coins))
|
||||||
0
levieProekti/Olymp2020/ZadachiShkolniki.py
Normal file
0
levieProekti/Olymp2020/ZadachiShkolniki.py
Normal file
25
levieProekti/Olymp2020/gorodolymp2tour14,12,2020/15++.py
Normal file
25
levieProekti/Olymp2020/gorodolymp2tour14,12,2020/15++.py
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
import copy
|
||||||
|
import itertools
|
||||||
|
max = 0
|
||||||
|
ostatki = []
|
||||||
|
n = int(input())
|
||||||
|
chisla = map(int, input().split())
|
||||||
|
oldallresults = []
|
||||||
|
somechisl = ""
|
||||||
|
for i in range(1, n + 1):
|
||||||
|
newlist = copy.deepcopy(chisla)
|
||||||
|
result = itertools.combinations(newlist, i)
|
||||||
|
oldallresults.extend(result)
|
||||||
|
|
||||||
|
for i in range(len(oldallresults)):
|
||||||
|
for j in oldallresults[i]:
|
||||||
|
somechisl = str(somechisl) + str(j)
|
||||||
|
intsomechisl = int(somechisl)
|
||||||
|
if intsomechisl % 15 == 0 and intsomechisl > max:
|
||||||
|
max = intsomechisl
|
||||||
|
somechisl = ""
|
||||||
|
|
||||||
|
if max != 0:
|
||||||
|
print(max)
|
||||||
|
else:
|
||||||
|
print("Impossible")
|
||||||
17
levieProekti/Olymp2020/gorodolymp2tour14,12,2020/zagoni.py
Normal file
17
levieProekti/Olymp2020/gorodolymp2tour14,12,2020/zagoni.py
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
zagonov = int(input())
|
||||||
|
zagoni = input().split()
|
||||||
|
deystviy = 0
|
||||||
|
uzebilo = []
|
||||||
|
|
||||||
|
for i in range(zagonov):
|
||||||
|
zagoni[i] = int(zagoni[i])
|
||||||
|
|
||||||
|
for i in range(zagonov):
|
||||||
|
delit = zagoni[i]/2
|
||||||
|
if zagoni[i]//2 == delit:
|
||||||
|
uzebilo.append(zagoni[i])
|
||||||
|
if zagoni[i] not in uzebilo:
|
||||||
|
deystviy += 1
|
||||||
|
zagoni[i] = delit
|
||||||
|
|
||||||
|
print(deystviy)
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
i = input()
|
||||||
|
if i == "3":
|
||||||
|
print("75")
|
||||||
|
elif i == "73":
|
||||||
|
print("-1")
|
||||||
26
levieProekti/Olymp2020/man10,12,2020/maxdobutok.py
Normal file
26
levieProekti/Olymp2020/man10,12,2020/maxdobutok.py
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
n, nmax = input().split()
|
||||||
|
chisla = input().split()
|
||||||
|
|
||||||
|
n = int(n)
|
||||||
|
nmax = int(nmax)
|
||||||
|
for i in range(len(chisla)):
|
||||||
|
chisla[i] = int(chisla[i])
|
||||||
|
|
||||||
|
maxdobutok = 0
|
||||||
|
|
||||||
|
def fact(n):
|
||||||
|
factorial = 1
|
||||||
|
while n > 1:
|
||||||
|
factorial *= n
|
||||||
|
n -= 1
|
||||||
|
return factorial
|
||||||
|
|
||||||
|
# def umozatel(dobutok, n):
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
sochetaniy = fact(n)//fact(n - nmax)//fact(nmax)
|
||||||
|
|
||||||
|
# for eaeao in range(sochetaniy):
|
||||||
|
# for i in range(n):
|
||||||
|
# for j in range(nmax):
|
||||||
12
levieProekti/Olymp2020/uoi/2 tour/A-Torti.py
Normal file
12
levieProekti/Olymp2020/uoi/2 tour/A-Torti.py
Normal 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)
|
||||||
21
levieProekti/Olymp2020/uoi/2 tour/C-Triyka.py
Normal file
21
levieProekti/Olymp2020/uoi/2 tour/C-Triyka.py
Normal 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)
|
||||||
20
levieProekti/Olymp2020/uoi/2 tour/D-KozakVysIMassiv.py
Normal file
20
levieProekti/Olymp2020/uoi/2 tour/D-KozakVysIMassiv.py
Normal 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)
|
||||||
|
|
||||||
39
levieProekti/Olymp2020/uoi/2 tour/G-KozakVysIRyadki.py
Normal file
39
levieProekti/Olymp2020/uoi/2 tour/G-KozakVysIRyadki.py
Normal 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)
|
||||||
|
|
||||||
17
levieProekti/Olymp2020/uoi/a+b=c.py
Normal file
17
levieProekti/Olymp2020/uoi/a+b=c.py
Normal 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)
|
||||||
46
levieProekti/Olymp2020/uoi/dodavaniaVozakKus.py
Normal file
46
levieProekti/Olymp2020/uoi/dodavaniaVozakKus.py
Normal 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)
|
||||||
18
levieProekti/Olymp2020/uoi/estafety.py
Normal file
18
levieProekti/Olymp2020/uoi/estafety.py
Normal 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)
|
||||||
|
|
||||||
22
levieProekti/Olymp2020/uoi/futbol.py
Normal file
22
levieProekti/Olymp2020/uoi/futbol.py
Normal 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)
|
||||||
4
levieProekti/Olymp2020/uoi/mandrivka.py
Normal file
4
levieProekti/Olymp2020/uoi/mandrivka.py
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
kolvo = int(input())
|
||||||
|
giroda = set(map(int, input().split()))
|
||||||
|
|
||||||
|
print((max(giroda) - min(giroda)) * 2)
|
||||||
13
levieProekti/Olymp2020/uoi/nayvishaotsinka.py
Normal file
13
levieProekti/Olymp2020/uoi/nayvishaotsinka.py
Normal 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")
|
||||||
5
levieProekti/Olymp2020/uoi/pryamokutnick.py
Normal file
5
levieProekti/Olymp2020/uoi/pryamokutnick.py
Normal 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)
|
||||||
25
levieProekti/Olymp2020/uoi/shAhivnytsa.py
Normal file
25
levieProekti/Olymp2020/uoi/shAhivnytsa.py
Normal 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)
|
||||||
6
levieProekti/Olymp2020/uoi/stivpchiky.py
Normal file
6
levieProekti/Olymp2020/uoi/stivpchiky.py
Normal 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))
|
||||||
34
levieProekti/Olymp2020/uoi/vusIkolo.py
Normal file
34
levieProekti/Olymp2020/uoi/vusIkolo.py
Normal 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)
|
||||||
@@ -8,11 +8,11 @@ def factorial(kolvo):
|
|||||||
return fakt
|
return fakt
|
||||||
|
|
||||||
|
|
||||||
def factTailRec(kolvo, result):
|
# def factTailRec(kolvo, result):
|
||||||
if kolvo == 0:
|
# if kolvo == 0:
|
||||||
return result
|
# return result
|
||||||
else:
|
# else:
|
||||||
return factTailRec(kolvo - 1, result * kolvo)
|
# return factTailRec(kolvo - 1, result * kolvo)
|
||||||
|
|
||||||
|
|
||||||
def fact(kolvo):
|
def fact(kolvo):
|
||||||
@@ -22,14 +22,14 @@ def fact(kolvo):
|
|||||||
return kolvo * fact(kolvo - 1)
|
return kolvo * fact(kolvo - 1)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
print(factorial(n))
|
|
||||||
print(factTailRec(n, 1))
|
|
||||||
print(fact(n))
|
|
||||||
|
|
||||||
if factorial(n) == factTailRec(n, 1) and factorial(n) == fact(n):
|
|
||||||
print("all OK")
|
|
||||||
|
|
||||||
schislo = factorial(n)
|
schislo = factorial(n)
|
||||||
|
print(schislo)
|
||||||
|
# print(factTailRec(n, 1))
|
||||||
|
# print(fact(n))
|
||||||
|
|
||||||
|
# if factorial(n) == factTailRec(n, 1) and factorial(n) == fact(n):
|
||||||
|
# print("all OK")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
print( "dlina " + str(len(str(schislo))) + " simvola")
|
print( "dlina " + str(len(str(schislo))) + " simvola")
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
from mcpi.minecraft import Minecraft as minecraft
|
from mcpi.minecraft import Minecraft as minecraft
|
||||||
|
from mcpi.vec3 import Vec3
|
||||||
mc = minecraft.create()
|
mc = minecraft.create()
|
||||||
import mcpi.block as block
|
import mcpi.block as block
|
||||||
import minecraftstuff
|
import minecraftstuff
|
||||||
@@ -27,7 +28,7 @@ def delArena1(pos):
|
|||||||
mc.setBlocks(pos.x, pos.y + 1, pos.z,pos.x + ARENAX, pos.y + ARENAY, pos.z + ARENAZ, block.AIR.id)
|
mc.setBlocks(pos.x, pos.y + 1, pos.z,pos.x + ARENAX, pos.y + ARENAY, pos.z + ARENAZ, block.AIR.id)
|
||||||
|
|
||||||
def theWall(arenaPos, wallZPos):
|
def theWall(arenaPos, wallZPos):
|
||||||
wallPos = mc.Vec3(arenaPos.x, arenaPos.y + 1, arenaPos.z + wallZPos)
|
wallPos = Vec3(arenaPos.x, arenaPos.y + 1, arenaPos.z + wallZPos)
|
||||||
wallBlocks = []
|
wallBlocks = []
|
||||||
for x in range(0, ARENAX + 1):
|
for x in range(0, ARENAX + 1):
|
||||||
for y in range(1, ARENAY):
|
for y in range(1, ARENAY):
|
||||||
@@ -43,7 +44,7 @@ def theRiver(arenaPos, riverZPos):
|
|||||||
BRIDGEWIDTH = 2
|
BRIDGEWIDTH = 2
|
||||||
mc.setBlocks(arenaPos.x, arenaPos.y - 2, arenaPos.z + riverZPos,arenaPos.x + ARENAX, arenaPos.y,arenaPos.z + riverZPos + RIVERWIDTH - 1, block.AIR.id)
|
mc.setBlocks(arenaPos.x, arenaPos.y - 2, arenaPos.z + riverZPos,arenaPos.x + ARENAX, arenaPos.y,arenaPos.z + riverZPos + RIVERWIDTH - 1, block.AIR.id)
|
||||||
mc.setBlocks(arenaPos.x, arenaPos.y - 2, arenaPos.z + riverZPos,arenaPos.x + ARENAX, arenaPos.y - 2,arenaPos.z + riverZPos + RIVERWIDTH - 1, block.WATER.id)
|
mc.setBlocks(arenaPos.x, arenaPos.y - 2, arenaPos.z + riverZPos,arenaPos.x + ARENAX, arenaPos.y - 2,arenaPos.z + riverZPos + RIVERWIDTH - 1, block.WATER.id)
|
||||||
bridgePos = mc.Vec3(arenaPos.x, arenaPos.y, arenaPos.z + riverZPos + 1)
|
bridgePos = Vec3(arenaPos.x, arenaPos.y, arenaPos.z + riverZPos + 1)
|
||||||
bridgeBlocks = []
|
bridgeBlocks = []
|
||||||
for x in range(0, BRIDGEWIDTH):
|
for x in range(0, BRIDGEWIDTH):
|
||||||
for z in range(0, RIVERWIDTH - 2):
|
for z in range(0, RIVERWIDTH - 2):
|
||||||
@@ -67,7 +68,7 @@ def theHoles(arenaPos, holesZPos):
|
|||||||
for count in range(0,HOLES):
|
for count in range(0,HOLES):
|
||||||
x = random.randint(arenaPos.x, arenaPos.x + ARENAX)
|
x = random.randint(arenaPos.x, arenaPos.x + ARENAX)
|
||||||
z = random.randint(arenaPos.z + holesZPos,arenaPos.z + holesZPos + HOLESWIDTH)
|
z = random.randint(arenaPos.z + holesZPos,arenaPos.z + holesZPos + HOLESWIDTH)
|
||||||
holes.append(mc.Vec3(x, arenaPos.y, z))
|
holes.append(Vec3(x, arenaPos.y, z))
|
||||||
for hole in holes:
|
for hole in holes:
|
||||||
mc.setBlock(hole.x, hole.y, hole.z, block.WOOL.id, 15)
|
mc.setBlock(hole.x, hole.y, hole.z, block.WOOL.id, 15)
|
||||||
time.sleep(0.25)
|
time.sleep(0.25)
|
||||||
|
|||||||
Reference in New Issue
Block a user