Все задачи на 5.10.17 13:00

This commit is contained in:
2017-10-05 13:08:02 +03:00
parent 93746b05d7
commit ca2ca71f63
120 changed files with 2343 additions and 0 deletions

14
uts/uts_17_aut_py/1/A.py Normal file
View File

@@ -0,0 +1,14 @@
a, b, d = list(map(int, input().split()))
if a < b:
if a + d >= b:
print(b)
elif a + d < b:
print(a+d)
elif a > b:
if a - d <= b:
print(b)
elif a - d > b:
print(a-d)
else:
print(b)

7
uts/uts_17_aut_py/1/B.py Normal file
View File

@@ -0,0 +1,7 @@
n = int(input())
lastnum = n
otv = ''
print(1, end=' ')
while lastnum <= 10**9 and lastnum > 1:
print(lastnum, end=' ')
lastnum = lastnum * n

14
uts/uts_17_aut_py/1/C.py Normal file
View File

@@ -0,0 +1,14 @@
n = int(input())
def conNS(x, si1 ,si2):
x = int(str(x), si1)
b = ''
while x > 0:
b, x = str(x%si2)+b, x//si2
return b
n = conNS(n, 5, 7)
n = sum(list(map(int, str(n))))
n = conNS(n, 10, 3)
print(n)

8
uts/uts_17_aut_py/1/D.py Normal file
View File

@@ -0,0 +1,8 @@
l, r, d = list(map(int, input().split()))
cel = l // d + 1
cur = d * cel
if l % d == 0:
print(l, end=' ')
while cur <= r:
print(cur, end=' ')
cur += d

2
uts/uts_17_aut_py/1/E.py Normal file
View File

@@ -0,0 +1,2 @@
from collections import Counter
print(Counter(input()).most_common()[0][0])

5
uts/uts_17_aut_py/1/F.py Normal file
View File

@@ -0,0 +1,5 @@
s = input()
de = input()
for i in de:
s = s.replace(i, '')
print(s)

8
uts/uts_17_aut_py/1/G.py Normal file
View File

@@ -0,0 +1,8 @@
from collections import Counter
s = input()
k = int(input())
ss = []
for i in Counter(s).most_common():
if i[1] >= k:
ss.append(i[0])
print(*sorted(ss))

4
uts/uts_17_aut_py/1/H.py Normal file
View File

@@ -0,0 +1,4 @@
from collections import Counter
n = int(input())
mas = list(map(int, input().split()))
print(Counter(mas).most_common()[0][0])

5
uts/uts_17_aut_py/1/I.py Normal file
View File

@@ -0,0 +1,5 @@
ser = int(input())
mas = list(map(int, input().split()))
rem = mas[0]
mas.sort()
print(mas.index(rem) + 1)

11
uts/uts_17_aut_py/1/J.py Normal file
View File

@@ -0,0 +1,11 @@
ser = int(input())
mas = list(map(int, input().split()))
ind = ser // 2
mas1 = mas[:ind]
mas2 = mas[ind:]
mas1.sort()
mas2.sort(reverse=True)
for i in mas1:
print(i, end=' ')
for i in mas2:
print(i, end=' ')

8
uts/uts_17_aut_py/1/K.py Normal file
View File

@@ -0,0 +1,8 @@
ser = int(input())
mas = list(map(int, input().split()))
from collections import Counter
cer = Counter(mas).most_common()
for i in cer:
if i[1] == 1:
print(i[0])
break

9
uts/uts_17_aut_py/1/L.py Normal file
View File

@@ -0,0 +1,9 @@
ser = int(input())
mas = list(map(int, input().split()))
kek = 0
while True:
if kek in mas:
kek += 1
else:
print(kek)
break

4
uts/uts_17_aut_py/2/A.py Normal file
View File

@@ -0,0 +1,4 @@
ser = int(input())
mas = list(map(int, input().split()))
mas.sort()
print(*mas)

9
uts/uts_17_aut_py/2/B.py Normal file
View File

@@ -0,0 +1,9 @@
ser = int(input())
mas = list(map(int, input().split()))
cnt = 0
for i in range(ser):
srav = mas[i]
for j in range(i, ser):
if srav > mas[j]:
cnt += 1
print(cnt)

11
uts/uts_17_aut_py/2/C.py Normal file
View File

@@ -0,0 +1,11 @@
ser = int(input())
ner = list(map(int, input().split()))
ner.sort()
if ser % 2 != 0:
print(ner[ser // 2])
else:
ma = (ser // 2) - 1
mi = (ser // 2)
lg = ner[mi] + ner[ma]
kek = lg / 2
print(kek)

1
uts/uts_17_aut_py/2/G.py Normal file
View File

@@ -0,0 +1 @@
print(*range(1, int(input())+1))

23
uts/uts_17_aut_py/3/A.py Normal file
View File

@@ -0,0 +1,23 @@
from itertools import permutations
n = int(input())
pool = list(map(int, input().split()))
pool.reverse()
maxim = 0
def play(nel):
c_nush = 0
c_bara = 0
last = 0
for cookie in nel:
if c_nush > c_bara:
c_bara += cookie
last = 1
elif c_bara > c_nush:
c_nush += cookie
last = 0
elif c_bara == c_nush and last == 0:
c_nush += cookie
elif c_bara == c_nush and last == 1:
c_bara += cookie
return c_nush
maxim = play(pool)
print(maxim)

View File

@@ -0,0 +1,24 @@
from itertools import permutations
import zlib, json
#n = int(input()) # Лучше не смотреть на это НЕ решение)
#pool = list(map(int, input().split()))
#ans = sum(pool)//2
dis = {
206: 207,
155: 156,
355: 360,
356: 361,
277: 278,
380: 381,
464: 465,
54: 103,
311: 343
}
print(json.dumps(dis))
print(json.loads(json.dumps(dis)))
kek = zlib.compress(bytearray(json.dumps(dis), encoding='UTF-8'), level=-1)
print(kek)
print(json.loads(str(zlib.decompress(kek), encoding='UTF-8')))
#if ans in dis:
# ans = dis[ans]
#print(ans)

View File

@@ -0,0 +1,23 @@
data = b'x\x9c%\x8f9\x0e\x031\x0c' \
b'\x03\xbf\xb2\xd8:' \
b'\x85.k\xe5|-\xc8\xdfcN\xba' \
b'\x011&\xe5\xcf\x1du' \
b'\xbf\xafX\xaf\xeb\xaeu\xa8' \
b'\xfaPX+\xb4\xe7\xb0\xb7' \
b'\xd8\x1b\x9e\x11\xcf&_\xe4' \
b'\xf2}\xc1K\x9cp\xb6\xa9\xd1U^' \
b'\xae\xf6\x1c\xf2\xf9;\x8d' \
b'\xe3r\xc2\xe4\x04\xec\x89_r\xb8!' \
b'\xb9!\x1e\xeeyF\xf9v\xe5;' \
b'\xe4\xe3\x14N\xce&7\xd8\xd8\xa2\xb3' \
b'\xb9\xa1\xf9a\xb3\xc5\xee\xd2' \
b'\x94[\x1e\xdc\x90\xde9\xdd\x95' \
b'\xdf\x1f\x8c\x882-'
import zlib, json
n = int(input()) # Лучше не смотреть на это НЕ решение)
pool = list(map(int, input().split()))
ans = sum(pool)//2
dis = json.loads(str(zlib.decompress(data), encoding='UTF-8'))
if str(ans) in dis:
ans = dis[str(ans)]
print(ans)

View File

@@ -0,0 +1,17 @@
import zlib, json
n = int(input())
pool = list(map(int, input().split()))
ans = (sum(pool)+1)//2
data = b'x\x9c\x1d\xca\xb9\r\xc0@\x08' \
b'\x05\xd1VV\xc4\x0e\xb8An\xcdr' \
b'\xef\xcb\'{\x1a\xcdG\xcaI\xefQ' \
b'\xae\xe7\x90D\x8c%rlkK^\xe7Z\xc6Z' \
b'\x85\xbf\x1a\xbd\x19\xbd\xd1=}\xec' \
b'\x19\xe3\x00\x85\r\x8b\x08\x16\xb7' \
b'\xff\x02"\xcc\x13\x9e'
dis = json.loads(str(zlib.decompress(data), encoding='UTF-8'))
try:
ans = dis[str(ans)]
except Exception:
pass
print(ans)

33
uts/uts_17_aut_py/3/B.py Normal file
View File

@@ -0,0 +1,33 @@
n, NAVALNIY = list(map(int, input().split()))
VSTRECHAS = []
for i in range(n):
VSTRECHAS.append(list(map(int, input().split())))
n = 1
for vst in VSTRECHAS:
vst.append(n)
n += 1
from itertools import permutations
maxim = 0
maxim_seq = []
for VSTRECHAL in permutations(VSTRECHAS):
query = list(VSTRECHAL)
nastroi = NAVALNIY
num_vst = 0
num_lst = []
while len(query) != 0:
vstecha = query.pop()
if vstecha[0] <= nastroi <= vstecha[1]:
nastroi += vstecha[2]
num_vst += 1
num_lst.append(vstecha[3])
else:
break
if num_vst > maxim:
maxim = num_vst
maxim_seq = num_lst
if maxim == n:
break
ans = []
print(maxim)
for i in maxim_seq:
print(i, end=' ')

22
uts/uts_17_aut_py/oop.py Normal file
View File

@@ -0,0 +1,22 @@
human_list = []
class Human:
def __init__(self):
self.__names = []
self.say = ''
human_list.append(self)
@property
def name(self):
return self.__names
@name.setter
def name(self, mas):
for k in mas:
self.__names.append(k.lower())
sam = Human
sam.name = 'KEK'
sam.say = 'MEME'
print(sam.say)

View File

@@ -0,0 +1,38 @@
import sys
from itertools import permutations
def x(a,b,c):
return int(a and b or (not a) and c or not b and (not c))
if __name__ == '__main__':
mas = []
for i in range(8):
print(bin(i))
mas.append(list(map(int, bin(i)[2:])))
print(mas)
for sr in mas:
if len(sr) == 1:
sr.insert(0, 0)
sr.insert(0, 0)
elif len(sr) < 3:
sr.insert(0, 0)
print(mas)
sas = ''
for i in mas:
kek = x(i[0], i[1], i[2])
sas = str(kek) + sas
sas = '0b' + sas
print(int(sas, base=2))
# 219
# 28
# 60
# =если($c3<e3;b$5;$e$2)
# 8
# 240
# 30
# 64
# 2
# 11111011

View File

@@ -0,0 +1,46 @@
import sys, os
from operator import xor
disk0 = ['0xA', '0x3', '0x0', '0x8', '0x8', '0x1']
disk1 = ['', '', '', '', '', '']
disk2 = ['0x5', '0x7', '0xB', '0x6', '0x6', '0xC']
a = disk0
b = disk1
c = disk2
for i in range(len(disk0)):
disk0[i] = int(disk0[i], base=16)
disk2[i] = int(disk2[i], base=16)
print(disk0)
print(disk2)
for i in range(len(disk0)):
if b[i] == '':
b[i] = xor(c[i], a[i])
elif c[i] == '':
c[i] = xor(a[i], b[i])
elif a[i] == '':
a[i] = xor(c[i], b[i])
tmp = a
a = b
b = c
c = tmp
print(disk1)
print(hex(sum(disk0) + sum(disk1)))
summ = 0
for i in range(0, len(disk0), 3):
summ += disk0[i]
summ += disk1[i]
print('Число: {0}'.format(i))
summ += disk1[i+1]
summ += disk2[i+1]
summ += disk2[i+2]
summ += disk0[i+2]
print(hex(summ))

View File

@@ -0,0 +1,20 @@
oldn = 2
s = 0
while s != 3203:
n = oldn
i = 2
s = 0
c = 0
while n != 1:
if n % i==0:
n = n // i
c = c +1
else:
s = s * 10 + c
c = 0
i = i + 1
s = s * 10 + c
s = s
oldn += 1
print(oldn-1)

View File

@@ -0,0 +1,35 @@
m = 1
count = 0
while count != 110:
count = 0
mas = {}
for i in range(1, m+1):
mass = {}
for j in range(1, m+1):
mass[j] = 0
mas[i] = mass
# Аалгоритм
k = 1
while k <= m:
n = 1
while n <= m:
mas[k][n] = mas[n][k] + k
mas[n][k] = mas[k][n] - n
n = n + 1
k = k + 1
k = m
while k >= 1:
n = m
while n >= 1:
mas[k][n] = mas[k][n] - mas[n][k]
n = n - 1
k = k - 1
# Пподсчёт
for i in range(1, m+1):
for j in range(1, m+1):
if mas[i][j] > 6:
count += 1
m += 1
print(count)
# Уурааа
print('При m = {0}, c = {1}'.format(m-1, count))