Все задачи на 5.10.17 13:00
This commit is contained in:
41
uts/session_py/1.py
Normal file
41
uts/session_py/1.py
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
from random import randint
|
||||||
|
#x=int(input())
|
||||||
|
#y=int(input())
|
||||||
|
x=10
|
||||||
|
y=10
|
||||||
|
sum=0;
|
||||||
|
maxoffset = 0;
|
||||||
|
cordx=0;
|
||||||
|
cordy=0;
|
||||||
|
mini = min(x,y)
|
||||||
|
mass = [[randint(0,1) for i in range(x)] for o in range(y)]
|
||||||
|
for i in range(y):
|
||||||
|
print(mass[i])
|
||||||
|
for i in range(y):
|
||||||
|
for o in range(x):
|
||||||
|
if mass[i][o] == 0:
|
||||||
|
sum=0;
|
||||||
|
ii = 0;
|
||||||
|
#print("found zero at ",o,i)
|
||||||
|
for ii in range(mini):
|
||||||
|
if ii+o >= x:
|
||||||
|
break
|
||||||
|
if ii+i >= y:
|
||||||
|
break
|
||||||
|
sum = sum + mass[i + ii][o + ii]
|
||||||
|
for oo in range(ii):
|
||||||
|
sum = sum + mass[i+ii][o+oo]
|
||||||
|
sum = sum + mass[i+oo][o+ii]
|
||||||
|
if sum != 0:
|
||||||
|
break
|
||||||
|
#print("end zero at offset", ii)
|
||||||
|
if (maxoffset< ii):
|
||||||
|
maxoffset = ii
|
||||||
|
cordx = o
|
||||||
|
cordy = i
|
||||||
|
#print("!write bigger offset")
|
||||||
|
print(cordx+1, cordy+1, cordx+maxoffset, cordy+maxoffset)
|
||||||
|
print('these numbers should be zeroes')
|
||||||
|
for i in range(cordy,cordy+maxoffset):
|
||||||
|
for o in range(cordx,cordx+maxoffset):
|
||||||
|
print(mass[i][o])
|
||||||
13
uts/session_py/10.py
Normal file
13
uts/session_py/10.py
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
from random import *
|
||||||
|
from math import *
|
||||||
|
|
||||||
|
n = 10000
|
||||||
|
k = 0
|
||||||
|
|
||||||
|
for i in range(n):
|
||||||
|
x = uniform(-sqrt(2)/3, sqrt(2)/3)
|
||||||
|
y = uniform(-sqrt(2)/3, sqrt(2)/3)
|
||||||
|
z = uniform(-sqrt(2)/3, sqrt(2)/3)
|
||||||
|
if ():
|
||||||
|
k+=1
|
||||||
|
print(k/n)
|
||||||
8
uts/session_py/18.02.17.py
Normal file
8
uts/session_py/18.02.17.py
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
import sys
|
||||||
|
sys.stdin = open("sta.txt", "r")
|
||||||
|
|
||||||
|
sta, n = list(map(int, input().split()))
|
||||||
|
s = []
|
||||||
|
for i in range(sta):
|
||||||
|
s.append(input())
|
||||||
|
print(s)
|
||||||
7
uts/session_py/2.py
Normal file
7
uts/session_py/2.py
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
n=7
|
||||||
|
mass = [[1 for i in range(n)]]
|
||||||
|
current_max = 1;
|
||||||
|
print(mass)
|
||||||
|
for i in range(1,n):
|
||||||
|
current_max = current_max +1;
|
||||||
|
cur_list = mass[i-1]
|
||||||
41
uts/session_py/3.py
Normal file
41
uts/session_py/3.py
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
import sys
|
||||||
|
|
||||||
|
problem_name = str('calendar')
|
||||||
|
sys.stdin = open(problem_name + ".in", "r")
|
||||||
|
# sys.stdout = open(problem_name+".out", "w")
|
||||||
|
|
||||||
|
def get_mass(num):
|
||||||
|
arr = []
|
||||||
|
n = num
|
||||||
|
while n > 0:
|
||||||
|
arr.append(n%10)
|
||||||
|
n = n//10
|
||||||
|
return arr
|
||||||
|
|
||||||
|
def bad_char(start, end, bad):
|
||||||
|
counterr = 0
|
||||||
|
for day in range(start, end):
|
||||||
|
an = get_mass(day)
|
||||||
|
for nu in num:
|
||||||
|
if nu in an:
|
||||||
|
counterr += 1
|
||||||
|
return counterr
|
||||||
|
|
||||||
|
|
||||||
|
n, k = map(int, input().split())
|
||||||
|
a = list(map(int, input().split()))
|
||||||
|
num = list(map(int, input().split()))
|
||||||
|
print(n,' ',k)
|
||||||
|
counter = 0
|
||||||
|
a.sort()
|
||||||
|
print(a)
|
||||||
|
lastmas = 0
|
||||||
|
lastcount = 0
|
||||||
|
|
||||||
|
for mounth in a:
|
||||||
|
if lastmas == mounth:
|
||||||
|
counter = counter + lastcount
|
||||||
|
else:
|
||||||
|
counter = counter + lastcount + lastcount + bad_char(lastmas, mounth, num)
|
||||||
|
lastmas = mounth
|
||||||
|
print(counter)
|
||||||
10
uts/session_py/4.py
Normal file
10
uts/session_py/4.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import sys
|
||||||
|
sys.stdin = open("input.txt", "r")
|
||||||
|
sys.stdout = open("output.txt", "w")
|
||||||
|
n = int(input())
|
||||||
|
count = 0
|
||||||
|
for i in range(n):
|
||||||
|
for j in list(map(int, input().split())):
|
||||||
|
count = count + j
|
||||||
|
count = count / 2
|
||||||
|
print(int(count))
|
||||||
9
uts/session_py/5.py
Normal file
9
uts/session_py/5.py
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
import sys
|
||||||
|
sys.stdin = open("input.txt", "r")
|
||||||
|
sys.stdout = open("output.txt", "w")
|
||||||
|
n, m = map(int, input().split())
|
||||||
|
n_mas = [0 for i in range(n)]
|
||||||
|
for i in range(m):
|
||||||
|
for j in list(map(int, input().split())):
|
||||||
|
n_mas[j-1] += 1
|
||||||
|
print(*n_mas)
|
||||||
19
uts/session_py/6.py
Normal file
19
uts/session_py/6.py
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
import sys
|
||||||
|
sys.stdin = open("input.txt", "r")
|
||||||
|
sys.stdout = open("output.txt", "w")
|
||||||
|
n, m = map(int, input().split())
|
||||||
|
mas = []
|
||||||
|
for i in range(n):
|
||||||
|
mas.append(list(map(int, input().split())))
|
||||||
|
ans = [[0 for i in range(m)] for j in range(n)]
|
||||||
|
for i in range(n):
|
||||||
|
for j in range(m):
|
||||||
|
dist = 1000
|
||||||
|
for k in range(n):
|
||||||
|
for l in range(m):
|
||||||
|
if mas[k][l] == 1:
|
||||||
|
dist = min(dist, abs(k - i) + abs(l-j))
|
||||||
|
ans[i][j] = dist
|
||||||
|
for i in range(len(ans)):
|
||||||
|
print(*ans[i])
|
||||||
|
#http://127.0.0.1:41017/
|
||||||
10
uts/session_py/7.py
Normal file
10
uts/session_py/7.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
from random import randint
|
||||||
|
|
||||||
|
k = 0
|
||||||
|
n = 100000
|
||||||
|
|
||||||
|
for i in range(n):
|
||||||
|
h = randint(1,6)
|
||||||
|
if (h == 2) or (h == 5):
|
||||||
|
k += 1;
|
||||||
|
print(k/n)
|
||||||
11
uts/session_py/8.py
Normal file
11
uts/session_py/8.py
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
from random import *
|
||||||
|
|
||||||
|
n = 10000
|
||||||
|
k = 0
|
||||||
|
|
||||||
|
for i in range(n):
|
||||||
|
y = randint(0, 7) + random()
|
||||||
|
x = randint(0, 9) + random()
|
||||||
|
if (y <= 4 * x) and (y <= 10-x) and (y >= 0):
|
||||||
|
k += 1
|
||||||
|
print((k/n)*80)
|
||||||
13
uts/session_py/9.py
Normal file
13
uts/session_py/9.py
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
from random import *
|
||||||
|
|
||||||
|
from math import cos, pi
|
||||||
|
|
||||||
|
n = 10000
|
||||||
|
k = 0
|
||||||
|
for i in range(n):
|
||||||
|
y = uniform(-1, 1)
|
||||||
|
x = uniform(-pi, pi)
|
||||||
|
if ((y <= cos(x)) and (x >= -pi) and (x <= pi) and (y >= 0)) \
|
||||||
|
or ((y >= cos(x)) and (x >= -pi) and (x <= pi) and (y <= 0)):
|
||||||
|
k += 1
|
||||||
|
print(k/n*pi*4)
|
||||||
26
uts/session_py/B.py
Normal file
26
uts/session_py/B.py
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
import sys
|
||||||
|
|
||||||
|
problem_name = str('input')
|
||||||
|
sys.stdin = open(problem_name + ".txt", "r")
|
||||||
|
sys.stdout = open("output.txt", "w")
|
||||||
|
|
||||||
|
n, m = map(int, input().split())
|
||||||
|
n_mas = list(map(int, input().split()))
|
||||||
|
m_mas = list(map(int, input().split()))
|
||||||
|
s = []
|
||||||
|
for i in n_mas:
|
||||||
|
if not (i in m_mas):
|
||||||
|
s.append(i)
|
||||||
|
for i in m_mas:
|
||||||
|
if not (i in n_mas):
|
||||||
|
s.append(i)
|
||||||
|
if s == []:
|
||||||
|
print('EQUAL')
|
||||||
|
else:
|
||||||
|
s.sort()
|
||||||
|
for i in s:
|
||||||
|
if i in n_mas:
|
||||||
|
print('+'+str(i))
|
||||||
|
else:
|
||||||
|
print('-'+str(i))
|
||||||
|
#vlaDDisLaVuYtk
|
||||||
10
uts/session_py/C.py
Normal file
10
uts/session_py/C.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
w, h, xo, yo, x, y = map(int, input().split())
|
||||||
|
|
||||||
|
l = abs(x-xo)+abs(y-yo)
|
||||||
|
ll = yo + abs(h-y) + abs(x-xo)
|
||||||
|
lll = h-yo+y+abs(x-xo)
|
||||||
|
llll = xo+abs(w-x)+abs(y-yo)
|
||||||
|
lllll = w-xo+x+abs(y-yo)
|
||||||
|
llllll = xo+yo+abs(h-y)+abs(w-x)
|
||||||
|
lllllll = abs(h-yo)+abs(w-xo)+x+y
|
||||||
|
print(min(l,ll,lll,llll,lllll,llllll,lllllll))
|
||||||
18
uts/session_py/Check.py
Normal file
18
uts/session_py/Check.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
import sys
|
||||||
|
sys.stdin = open("input.txt", "r")
|
||||||
|
#sys.stdout = open("output.txt", "w")
|
||||||
|
|
||||||
|
def dfs(graph, start):
|
||||||
|
visited, stack = set(), [start]
|
||||||
|
while stack:
|
||||||
|
vertex = stack.pop()
|
||||||
|
if vertex not in visited:
|
||||||
|
visited.add(vertex)
|
||||||
|
stack.extend(graph[vertex] - visited)
|
||||||
|
return visited
|
||||||
|
|
||||||
|
n = int(input())
|
||||||
|
mas = [list(map(int, input().split())) for i in range(n)]
|
||||||
|
visit = []
|
||||||
|
|
||||||
|
print(mas)
|
||||||
35
uts/session_py/E.py
Normal file
35
uts/session_py/E.py
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
import sys
|
||||||
|
problem_name = str('input')
|
||||||
|
sys.stdout = open("output.txt", "w")
|
||||||
|
def unff(number, arr, base):
|
||||||
|
res = ""
|
||||||
|
while number > 0:
|
||||||
|
y = arr[number % base]
|
||||||
|
res = y + res
|
||||||
|
number = int(number // base)
|
||||||
|
return res
|
||||||
|
dec_mas = []
|
||||||
|
arr = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F']
|
||||||
|
f = open(problem_name + ".txt")
|
||||||
|
s = []
|
||||||
|
for line in f:
|
||||||
|
s.append(line)
|
||||||
|
for od in range(1, len(s)):
|
||||||
|
dec_mas.append(int(s[od]))
|
||||||
|
b = int(s[0])
|
||||||
|
count = {}
|
||||||
|
count = {i: 0 for i in arr}
|
||||||
|
for i in dec_mas:
|
||||||
|
un = unff(i, arr, b)
|
||||||
|
s = []
|
||||||
|
for o in un:
|
||||||
|
if not(o in s):
|
||||||
|
count[o] += 1
|
||||||
|
s.append(o)
|
||||||
|
maxim = 0
|
||||||
|
index = 0
|
||||||
|
for i in count:
|
||||||
|
if count[i] > maxim:
|
||||||
|
maxim = count[i]
|
||||||
|
index = i
|
||||||
|
print(index)
|
||||||
4
uts/session_py/J.py
Normal file
4
uts/session_py/J.py
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
n = int(input())
|
||||||
|
matx = []
|
||||||
|
for i in range(n):
|
||||||
|
matx.append(list(map(int, input().split())))
|
||||||
2
uts/session_py/O2017_MT/kek.in
Normal file
2
uts/session_py/O2017_MT/kek.in
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
В сто сорок солнц закат пылал, в июль катилось лето.
|
||||||
|
Мы не рабы, рабы не мы.
|
||||||
18
uts/session_py/O2017_MT/УВВ_ZZ1.py
Normal file
18
uts/session_py/O2017_MT/УВВ_ZZ1.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
def swi(g):
|
||||||
|
if g == 1:
|
||||||
|
return 0, False
|
||||||
|
if g == 0:
|
||||||
|
return 1, True
|
||||||
|
a = input()
|
||||||
|
b = input()
|
||||||
|
ex = []
|
||||||
|
g = 0
|
||||||
|
for i in b:
|
||||||
|
g, doo = swi(g)
|
||||||
|
if (doo) and (not (i in ex)):
|
||||||
|
ex.append(i)
|
||||||
|
b = ''
|
||||||
|
for i in a:
|
||||||
|
if not (i in ex):
|
||||||
|
b += i
|
||||||
|
print(b)
|
||||||
3
uts/session_py/calendar.in
Normal file
3
uts/session_py/calendar.in
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
12 2
|
||||||
|
31 28 31 30 31 30 31 31 30 31 30 31
|
||||||
|
0 3
|
||||||
20
uts/session_py/dist_march_2k17/Business.py
Normal file
20
uts/session_py/dist_march_2k17/Business.py
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
import sys
|
||||||
|
|
||||||
|
sys.stdin = open("input.txt", "r")
|
||||||
|
sys.stdout = open("output.txt", "w")
|
||||||
|
|
||||||
|
n = int(input())
|
||||||
|
c = [None for i in range(n+1)]
|
||||||
|
for i in range(1, n, 2):
|
||||||
|
c[i] = 0
|
||||||
|
c[2] = 1
|
||||||
|
c[0] = 1
|
||||||
|
def recursion(n, c):
|
||||||
|
if c[n] != None:
|
||||||
|
return c[n]
|
||||||
|
kkk = 0
|
||||||
|
for i in range(1, n):
|
||||||
|
kkk += recursion(i-1, c) * recursion(n-i-1, c)
|
||||||
|
c[n] = kkk
|
||||||
|
return kkk
|
||||||
|
print(recursion(n, c))
|
||||||
26
uts/session_py/dist_march_2k17/Peter.py
Normal file
26
uts/session_py/dist_march_2k17/Peter.py
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
import sys
|
||||||
|
|
||||||
|
sys.stdin = open("input.txt", "r")
|
||||||
|
sys.stdout = open("output.txt", "w")
|
||||||
|
s = int(input())
|
||||||
|
l = 1
|
||||||
|
h = int(10e18)
|
||||||
|
while l <= h:
|
||||||
|
mid = (l+h)//2
|
||||||
|
x = mid
|
||||||
|
now = mid
|
||||||
|
while x != 0:
|
||||||
|
st = str(x)
|
||||||
|
st = st[:-1]
|
||||||
|
if len(st) == 0:
|
||||||
|
break
|
||||||
|
x = int(st)
|
||||||
|
now += x
|
||||||
|
if now == s :
|
||||||
|
print(mid)
|
||||||
|
quit()
|
||||||
|
elif now < s :
|
||||||
|
l = mid + 1
|
||||||
|
else :
|
||||||
|
h = mid - 1
|
||||||
|
print(-1)
|
||||||
24
uts/session_py/dist_march_2k17/Sherlock.py
Normal file
24
uts/session_py/dist_march_2k17/Sherlock.py
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
import sys
|
||||||
|
|
||||||
|
sys.stdin = open("input.txt", "r")
|
||||||
|
sys.stdout = open("output.txt", "w")
|
||||||
|
|
||||||
|
test_num = int(input())
|
||||||
|
for test in range(test_num):
|
||||||
|
b = 'NO'
|
||||||
|
n = int(input())
|
||||||
|
a = list(map(int, input().split()))
|
||||||
|
if n == 1:
|
||||||
|
b = 'YES'
|
||||||
|
elif n == 2:
|
||||||
|
b = 'NO'
|
||||||
|
else:
|
||||||
|
left = 0
|
||||||
|
right = sum(a[1:])
|
||||||
|
for i in range(1, n-1):
|
||||||
|
left += a[i - 1]
|
||||||
|
right -= a[i]
|
||||||
|
if left == right:
|
||||||
|
b = 'YES'
|
||||||
|
break
|
||||||
|
print(b)
|
||||||
16
uts/session_py/dist_march_2k17/String.py
Normal file
16
uts/session_py/dist_march_2k17/String.py
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import sys
|
||||||
|
|
||||||
|
sys.stdin = open("input.txt", "r")
|
||||||
|
sys.stdout = open("output.txt", "w")
|
||||||
|
orig, end = input(), input()
|
||||||
|
|
||||||
|
while len(end) > len(orig):
|
||||||
|
if end[-1] == 'A':
|
||||||
|
end = end[:-1]
|
||||||
|
else:
|
||||||
|
end = end[:-1][::-1]
|
||||||
|
|
||||||
|
if orig == end:
|
||||||
|
print('POSSIBLE')
|
||||||
|
else:
|
||||||
|
print('IMPOSSIBLE')
|
||||||
1
uts/session_py/dist_march_2k17/input.txt
Normal file
1
uts/session_py/dist_march_2k17/input.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
50
|
||||||
6
uts/session_py/input.txt
Normal file
6
uts/session_py/input.txt
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
5
|
||||||
|
0 1 3 1 4
|
||||||
|
1 0 4 5 2
|
||||||
|
3 4 0 8 4
|
||||||
|
1 5 8 0 3
|
||||||
|
4 2 4 3 0
|
||||||
1
uts/session_py/output.txt
Normal file
1
uts/session_py/output.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
[[0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]]
|
||||||
9
uts/session_py/sta.txt
Normal file
9
uts/session_py/sta.txt
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
8 15
|
||||||
|
Музыкальная
|
||||||
|
Историческая
|
||||||
|
Минное поле
|
||||||
|
Арм рестлинг
|
||||||
|
Математическая
|
||||||
|
Волейбол
|
||||||
|
ОБЖ
|
||||||
|
Перевязочная
|
||||||
52
uts/some_cpp/askquestion.cpp
Normal file
52
uts/some_cpp/askquestion.cpp
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
#include <signal.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <iostream>
|
||||||
|
#include <sqlite3.h>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
bool answered = 0;
|
||||||
|
string one = "";
|
||||||
|
|
||||||
|
void oloop() {
|
||||||
|
while (!answered) {
|
||||||
|
cout << "Enter one" << endl << ">";
|
||||||
|
cin >> one;
|
||||||
|
if (one == "one") {
|
||||||
|
answered = 1;
|
||||||
|
cout << "Yep!" << endl;
|
||||||
|
exit(0);
|
||||||
|
} else { cout << "Wrong!" << endl; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void handler(int s) {
|
||||||
|
cout << endl << "Don't even try to exit!" << endl;
|
||||||
|
oloop();
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char** argv) {
|
||||||
|
//God save the stackoverflow!
|
||||||
|
signal(SIGINT, handler);
|
||||||
|
signal(SIGTERM, handler);
|
||||||
|
signal(SIGHUP, handler);
|
||||||
|
signal(SIGTSTP, handler);
|
||||||
|
signal(SIGSTOP, handler);
|
||||||
|
|
||||||
|
if (!getenv("SSH_CLIENT")) { exit(0); }
|
||||||
|
string env_ip = getenv("SSH_CLIENT");
|
||||||
|
|
||||||
|
string cur_ip = "";
|
||||||
|
for (int i = 0; i < env_ip.length(); i++) {
|
||||||
|
if (env_ip[i] == ' ') { break; }
|
||||||
|
cur_ip = cur_ip + env_ip[i];
|
||||||
|
}
|
||||||
|
cout << "Enter main loop" << endl;
|
||||||
|
cout << "Your IP is: " << cur_ip << endl;
|
||||||
|
oloop();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
1
uts/some_cpp/session
Submodule
1
uts/some_cpp/session
Submodule
Submodule uts/some_cpp/session added at 2cd53bcf6c
14
uts/uts_17_aut_py/1/A.py
Normal file
14
uts/uts_17_aut_py/1/A.py
Normal 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
7
uts/uts_17_aut_py/1/B.py
Normal 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
14
uts/uts_17_aut_py/1/C.py
Normal 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
8
uts/uts_17_aut_py/1/D.py
Normal 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
2
uts/uts_17_aut_py/1/E.py
Normal 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
5
uts/uts_17_aut_py/1/F.py
Normal 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
8
uts/uts_17_aut_py/1/G.py
Normal 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
4
uts/uts_17_aut_py/1/H.py
Normal 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
5
uts/uts_17_aut_py/1/I.py
Normal 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
11
uts/uts_17_aut_py/1/J.py
Normal 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
8
uts/uts_17_aut_py/1/K.py
Normal 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
9
uts/uts_17_aut_py/1/L.py
Normal 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
4
uts/uts_17_aut_py/2/A.py
Normal 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
9
uts/uts_17_aut_py/2/B.py
Normal 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
11
uts/uts_17_aut_py/2/C.py
Normal 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
1
uts/uts_17_aut_py/2/G.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
print(*range(1, int(input())+1))
|
||||||
23
uts/uts_17_aut_py/3/A.py
Normal file
23
uts/uts_17_aut_py/3/A.py
Normal 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)
|
||||||
24
uts/uts_17_aut_py/3/A_RUSH.py
Normal file
24
uts/uts_17_aut_py/3/A_RUSH.py
Normal 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)
|
||||||
23
uts/uts_17_aut_py/3/A_RUSH_Z.py
Normal file
23
uts/uts_17_aut_py/3/A_RUSH_Z.py
Normal 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)
|
||||||
17
uts/uts_17_aut_py/3/A_TYP.py
Normal file
17
uts/uts_17_aut_py/3/A_TYP.py
Normal 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
33
uts/uts_17_aut_py/3/B.py
Normal 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
22
uts/uts_17_aut_py/oop.py
Normal 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)
|
||||||
38
uts/uts_17_aut_py/test_02.py
Normal file
38
uts/uts_17_aut_py/test_02.py
Normal 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
|
||||||
46
uts/uts_17_aut_py/test_03.py
Normal file
46
uts/uts_17_aut_py/test_03.py
Normal 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))
|
||||||
20
uts/uts_17_aut_py/test_04.py
Normal file
20
uts/uts_17_aut_py/test_04.py
Normal 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)
|
||||||
35
uts/uts_17_aut_py/test_05.py
Normal file
35
uts/uts_17_aut_py/test_05.py
Normal 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))
|
||||||
13
uts/uts_2017_aut_cpp/CMakeLists.txt
Normal file
13
uts/uts_2017_aut_cpp/CMakeLists.txt
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.9)
|
||||||
|
project(uts_2017_aut)
|
||||||
|
|
||||||
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
|
||||||
|
find_package(OpenMP)
|
||||||
|
if (OPENMP_FOUND)
|
||||||
|
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
|
||||||
|
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(SOURCE_FILES main.cpp)
|
||||||
|
add_executable(uts_2017_aut ${SOURCE_FILES})
|
||||||
48
uts/uts_2017_aut_cpp/main.cpp
Normal file
48
uts/uts_2017_aut_cpp/main.cpp
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
int compare(const void * x1, const void * x2)
|
||||||
|
{
|
||||||
|
return ( *(int*)x1 - *(int*)x2 );
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
unsigned long long n, b, p;
|
||||||
|
cin >> n >> b >> p;
|
||||||
|
unsigned long long a[n];
|
||||||
|
for (long i = 0; i < n; i++) {
|
||||||
|
a[i] = (unsigned long long)pow(b, i+1) % p;
|
||||||
|
}
|
||||||
|
unsigned long long ma;
|
||||||
|
unsigned long long mi;
|
||||||
|
long lastclean;
|
||||||
|
for (long j = 0; j < n-1; j++) {
|
||||||
|
mi = 10000000000;
|
||||||
|
ma = 0;
|
||||||
|
for (long i = 0; i < n; i++) {
|
||||||
|
bool change = false;
|
||||||
|
if (a[i] >= ma && a[i] != 10000000000) {
|
||||||
|
ma = a[i];
|
||||||
|
change = true;
|
||||||
|
lastclean = i;
|
||||||
|
}
|
||||||
|
if (a[i] <= mi && a[i] != 10000000000) {
|
||||||
|
mi = a[i];
|
||||||
|
change = true;
|
||||||
|
lastclean = i;
|
||||||
|
}
|
||||||
|
if (change) {
|
||||||
|
a[i] = 10000000000;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
a[lastclean] = (mi + ma) % p;
|
||||||
|
cout << a[lastclean] << ' ';
|
||||||
|
}
|
||||||
|
//cout << '\n';
|
||||||
|
//for (long i = 0; i < n; i++) {
|
||||||
|
// cout << a[i] << ' ';
|
||||||
|
//}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
40
uts/uts_2017_sum_cpp/3/B.cpp
Normal file
40
uts/uts_2017_sum_cpp/3/B.cpp
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
//#define DEBUG
|
||||||
|
int main() {
|
||||||
|
#ifndef DEBUG
|
||||||
|
freopen("count.in", "r", stdin);
|
||||||
|
freopen("count.out", "w", stdout);
|
||||||
|
#else
|
||||||
|
freopen("../count.in", "r", stdin);
|
||||||
|
#endif
|
||||||
|
long long x[31][31];
|
||||||
|
long long m = 0;
|
||||||
|
long long n = 0;
|
||||||
|
long long s = 0;
|
||||||
|
for (int i = 0; i <= 31; i++) {
|
||||||
|
for (int j = 0; i <= 31; i++) {
|
||||||
|
x[i][j] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int i = 0; i <= 30; i++) {
|
||||||
|
x[1][i] = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
cin >> m >> n;
|
||||||
|
|
||||||
|
for (int i = 2; i <= m; i++) {
|
||||||
|
for (int j = 0; j <= n; j++) {
|
||||||
|
for (int k = 0; k <= j; k++) {
|
||||||
|
x[i][j] += x[i-1][k];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int i = 0; i <= n; i++) {
|
||||||
|
s += x[m][i];
|
||||||
|
}
|
||||||
|
cout << s;
|
||||||
|
fclose(stdout);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
1
uts/uts_2017_sum_cpp/3/count.in
Normal file
1
uts/uts_2017_sum_cpp/3/count.in
Normal file
@@ -0,0 +1 @@
|
|||||||
|
3 5
|
||||||
63
uts/uts_2017_sum_cpp/4/A.cpp
Normal file
63
uts/uts_2017_sum_cpp/4/A.cpp
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <bits/stdc++.h>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
const int MAXN = 1e6;
|
||||||
|
vector<int> tree[MAXN];
|
||||||
|
int lel[MAXN];
|
||||||
|
int in[MAXN];
|
||||||
|
int out[MAXN];
|
||||||
|
int timer = 0;
|
||||||
|
|
||||||
|
bool is_anc(int a, int b) {
|
||||||
|
return (in[a] <= in[b]) && (out[b] <= out[a]);
|
||||||
|
}
|
||||||
|
|
||||||
|
void dfs(int v, int p, int h) {
|
||||||
|
lel[v] = h;
|
||||||
|
in[v] = timer++;
|
||||||
|
for (int u : tree[v]) {
|
||||||
|
if (u == p) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
dfs(u, v, h + 1);
|
||||||
|
}
|
||||||
|
out[v] = timer++;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
//assert(freopen("../4/A.txt", "r", stdin));
|
||||||
|
ios_base::sync_with_stdio(false);
|
||||||
|
cin.tie(0);
|
||||||
|
|
||||||
|
int n, m, k;
|
||||||
|
|
||||||
|
cin >> n >> m >> k;
|
||||||
|
|
||||||
|
for (int i = 1; i < n; i++) {
|
||||||
|
int v;
|
||||||
|
cin >> v;
|
||||||
|
tree[i].push_back(--v);
|
||||||
|
tree[v].push_back(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
dfs(0, -1, 0);
|
||||||
|
|
||||||
|
for (int i = 0; i < m; i++) {
|
||||||
|
int vi, ui;
|
||||||
|
cin >> vi >> ui;
|
||||||
|
--vi;
|
||||||
|
--ui;
|
||||||
|
|
||||||
|
if (!is_anc(vi, ui)){
|
||||||
|
cout << "no\n";
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lel[ui] - lel[vi] > k) {
|
||||||
|
cout << "no\n";
|
||||||
|
} else {
|
||||||
|
cout << "yes\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
6
uts/uts_2017_sum_cpp/4/A.txt
Normal file
6
uts/uts_2017_sum_cpp/4/A.txt
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
5 4 3
|
||||||
|
1 1 1 4
|
||||||
|
3 3
|
||||||
|
1 3
|
||||||
|
1 3
|
||||||
|
2 4
|
||||||
71
uts/uts_2017_sum_cpp/4/B.cpp
Normal file
71
uts/uts_2017_sum_cpp/4/B.cpp
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
//
|
||||||
|
// Created by vlad on 29.06.17.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <vector>
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
const int MAXN = 1e6;
|
||||||
|
const int MAXLOG = 25;
|
||||||
|
vector<int> tree[MAXN];
|
||||||
|
int lel[MAXN];
|
||||||
|
int in[MAXN];
|
||||||
|
int out[MAXN];
|
||||||
|
int timer = 0;
|
||||||
|
int up[MAXN][MAXLOG];
|
||||||
|
|
||||||
|
bool is_anc(int a, int b) {
|
||||||
|
return (in[a] <= in[b]) && (out[b] <= out[a]);
|
||||||
|
}
|
||||||
|
|
||||||
|
void add(int a, int p) {
|
||||||
|
up[a][0] = p;
|
||||||
|
for (int i = 1; i < MAXLOG; i++) up[a][i] = up[up[a][i - 1]][i - 1];
|
||||||
|
}
|
||||||
|
|
||||||
|
void dfs(int v, int p, int h) {
|
||||||
|
lel[v] = h;
|
||||||
|
in[v] = timer++;
|
||||||
|
for (int u : tree[v]) {
|
||||||
|
if (u == p) continue;
|
||||||
|
add(u, v);
|
||||||
|
dfs(u, v, h + 1);
|
||||||
|
}
|
||||||
|
out[v] = timer++;
|
||||||
|
}
|
||||||
|
|
||||||
|
int lca(int a, int b){
|
||||||
|
if (is_anc(a, b)) return a;
|
||||||
|
if (is_anc(b, a)) return b;
|
||||||
|
for(int i = MAXLOG-1; i>=0; --i){
|
||||||
|
int v = up[a][i];
|
||||||
|
if (!is_anc(v, b)) a = v;
|
||||||
|
}
|
||||||
|
return up[a][0];
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
//assert(freopen("../4/B.txt", "r", stdin));
|
||||||
|
ios_base::sync_with_stdio(false);
|
||||||
|
cin.tie(0);
|
||||||
|
int n, m;
|
||||||
|
cin >> n;
|
||||||
|
for (int i = 1; i < n; i++) {
|
||||||
|
int pi, qi;
|
||||||
|
cin >> pi >> qi;
|
||||||
|
tree[--pi].push_back(--qi);
|
||||||
|
tree[qi].push_back(pi);
|
||||||
|
}
|
||||||
|
cin >> m;
|
||||||
|
dfs(0, -1, 0);
|
||||||
|
for (int i = 0; i < m; i++) {
|
||||||
|
int ai, bi;
|
||||||
|
cin >> ai >> bi;
|
||||||
|
ai--;
|
||||||
|
bi--;
|
||||||
|
cout << lca(ai, bi) + 1 << endl;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
11
uts/uts_2017_sum_cpp/4/B.txt
Normal file
11
uts/uts_2017_sum_cpp/4/B.txt
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
6
|
||||||
|
6 3
|
||||||
|
5 6
|
||||||
|
2 1
|
||||||
|
2 4
|
||||||
|
4 5
|
||||||
|
4
|
||||||
|
6 1
|
||||||
|
2 4
|
||||||
|
4 4
|
||||||
|
5 3
|
||||||
BIN
uts/uts_2017_sum_cpp/4/LCA.pdf
Normal file
BIN
uts/uts_2017_sum_cpp/4/LCA.pdf
Normal file
Binary file not shown.
83
uts/uts_2017_sum_cpp/4/read.cpp
Normal file
83
uts/uts_2017_sum_cpp/4/read.cpp
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
//
|
||||||
|
// Created by vlad on 29.06.17.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include <cstdio>
|
||||||
|
|
||||||
|
/** Interface */
|
||||||
|
|
||||||
|
inline int readChar();
|
||||||
|
template <class T = int> inline T readInt();
|
||||||
|
template <class T> inline void writeInt( T x, char end = 0 );
|
||||||
|
inline void writeChar( int x );
|
||||||
|
inline void writeWord( const char *s );
|
||||||
|
|
||||||
|
/** Read */
|
||||||
|
|
||||||
|
static const int buf_size = 4096;
|
||||||
|
|
||||||
|
inline int getChar() {
|
||||||
|
static char buf[buf_size];
|
||||||
|
static int len = 0, pos = 0;
|
||||||
|
if (pos == len)
|
||||||
|
pos = 0, len = fread(buf, 1, buf_size, stdin);
|
||||||
|
if (pos == len)
|
||||||
|
return -1;
|
||||||
|
return buf[pos++];
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int readChar() {
|
||||||
|
int c = getChar();
|
||||||
|
while (c <= 32)
|
||||||
|
c = getChar();
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
inline T readInt() {
|
||||||
|
int s = 1, c = readChar();
|
||||||
|
T x = 0;
|
||||||
|
if (c == '-')
|
||||||
|
s = -1, c = getChar();
|
||||||
|
while ('0' <= c && c <= '9')
|
||||||
|
x = x * 10 + c - '0', c = getChar();
|
||||||
|
return s == 1 ? x : -x;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Write */
|
||||||
|
|
||||||
|
static int write_pos = 0;
|
||||||
|
static char write_buf[buf_size];
|
||||||
|
|
||||||
|
inline void writeChar( int x ) {
|
||||||
|
if (write_pos == buf_size)
|
||||||
|
fwrite(write_buf, 1, buf_size, stdout), write_pos = 0;
|
||||||
|
write_buf[write_pos++] = x;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
inline void writeInt( T x, char end ) {
|
||||||
|
if (x < 0)
|
||||||
|
writeChar('-'), x = -x;
|
||||||
|
|
||||||
|
char s[24];
|
||||||
|
int n = 0;
|
||||||
|
while (x || !n)
|
||||||
|
s[n++] = '0' + x % 10, x /= 10;
|
||||||
|
while (n--)
|
||||||
|
writeChar(s[n]);
|
||||||
|
if (end)
|
||||||
|
writeChar(end);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void writeWord( const char *s ) {
|
||||||
|
while (*s)
|
||||||
|
writeChar(*s++);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Flusher {
|
||||||
|
~Flusher() {
|
||||||
|
if (write_pos)
|
||||||
|
fwrite(write_buf, 1, write_pos, stdout), write_pos = 0;
|
||||||
|
}
|
||||||
|
} flusher;
|
||||||
26
uts/uts_2017_sum_cpp/5/A.cpp
Normal file
26
uts/uts_2017_sum_cpp/5/A.cpp
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
//
|
||||||
|
// Created by vlad on 30.06.17.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
assert(freopen("../5/A.txt", "r", stdin));
|
||||||
|
int n;
|
||||||
|
cin >> n;
|
||||||
|
for (int i = 0; i < n; i++) {
|
||||||
|
int len;
|
||||||
|
cin >> len;
|
||||||
|
if (len > 437) {
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
cout << "Crash " << ++i << "\n";
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cout << "No crash\n";
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
2
uts/uts_2017_sum_cpp/5/A.txt
Normal file
2
uts/uts_2017_sum_cpp/5/A.txt
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
5
|
||||||
|
700 437 800 13 900
|
||||||
3
uts/uts_2017_sum_cpp/5/C.cpp
Normal file
3
uts/uts_2017_sum_cpp/5/C.cpp
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
//
|
||||||
|
// Created by vlad on 30.06.17.
|
||||||
|
//
|
||||||
11
uts/uts_2017_sum_cpp/CMakeLists.txt
Normal file
11
uts/uts_2017_sum_cpp/CMakeLists.txt
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.8)
|
||||||
|
project(uts_2017_sum)
|
||||||
|
|
||||||
|
set(CMAKE_CXX_STANDARD 11)
|
||||||
|
|
||||||
|
set(SOURCE_FILES main.cpp)
|
||||||
|
add_executable(uts_2017_sum ${SOURCE_FILES})
|
||||||
|
add_executable(28_B 3/B.cpp)
|
||||||
|
add_executable(29_A 4/A.cpp)
|
||||||
|
add_executable(29_B 4/B.cpp)
|
||||||
|
add_executable(30_A 5/A.cpp)
|
||||||
8
uts/uts_2017_sum_cpp/main.cpp
Normal file
8
uts/uts_2017_sum_cpp/main.cpp
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
cout << "Hello\n";
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
44
uts/uts_2017_sum_cs/C_Redact_rast/C_Redact_rast.csproj
Normal file
44
uts/uts_2017_sum_cs/C_Redact_rast/C_Redact_rast.csproj
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
|
||||||
|
<ProjectGuid>{1E8CCFCD-A327-4E5F-AE82-147D361DAEAF}</ProjectGuid>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<RootNamespace>C_Redact_rast</RootNamespace>
|
||||||
|
<AssemblyName>C_Redact_rast</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<ExternalConsole>true</ExternalConsole>
|
||||||
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release</OutputPath>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<ExternalConsole>true</ExternalConsole>
|
||||||
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="System" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="Program.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="distance.in">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||||
|
</Project>
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup Condition=" '$(RunConfiguration)' == 'Default' ">
|
||||||
|
<StartAction>Project</StartAction>
|
||||||
|
<ExternalConsole>false</ExternalConsole>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
||||||
56
uts/uts_2017_sum_cs/C_Redact_rast/Program.cs
Normal file
56
uts/uts_2017_sum_cs/C_Redact_rast/Program.cs
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace A_Yadra
|
||||||
|
{
|
||||||
|
class MainClass
|
||||||
|
{
|
||||||
|
public static void Main(string[] args)
|
||||||
|
{
|
||||||
|
FileStream fs = new FileStream("distance.out", FileMode.Create);
|
||||||
|
TextWriter tmp = Console.Out;
|
||||||
|
StreamWriter sw = new StreamWriter(fs);
|
||||||
|
#if DEBUG
|
||||||
|
Console.SetOut(tmp);
|
||||||
|
#else
|
||||||
|
Console.SetOut(sw);
|
||||||
|
#endif
|
||||||
|
FileStream ii = new FileStream("distance.in", FileMode.Open);
|
||||||
|
TextReader tmpi = Console.In;
|
||||||
|
StreamReader swi = new StreamReader(ii);
|
||||||
|
#if false
|
||||||
|
Console.SetIn(tmpi);
|
||||||
|
#else
|
||||||
|
Console.SetIn(swi);
|
||||||
|
#endif
|
||||||
|
//Here comes the plane
|
||||||
|
string s1 = Console.ReadLine();
|
||||||
|
string s2 = Console.ReadLine();
|
||||||
|
int[,] D = new int[s1.Length + 1, s2.Length + 1];
|
||||||
|
D[0, 0] = 0;
|
||||||
|
for (int j = 1; j <= s2.Length; j++)
|
||||||
|
{
|
||||||
|
D[0, j] = D[0, j - 1] + 1;
|
||||||
|
};
|
||||||
|
for (int i = 1; i <= s1.Length; i++)
|
||||||
|
{
|
||||||
|
D[i, 0] = D[i - 1, 0] + 1;
|
||||||
|
for (int j = 1; j <= s2.Length; j++)
|
||||||
|
{
|
||||||
|
if (s1[i-1] != s2[j-1])
|
||||||
|
{
|
||||||
|
D[i, j] = Math.Min(D[i - 1, j] + 1, Math.Min(D[i, j - 1] + 1, D[i - 1, j - 1] + 1));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
D[i, j] = D[i - 1, j - 1];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
Console.WriteLine(D[s1.Length, s2.Length]);
|
||||||
|
//ENDS
|
||||||
|
sw.Close();
|
||||||
|
swi.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
26
uts/uts_2017_sum_cs/C_Redact_rast/Properties/AssemblyInfo.cs
Normal file
26
uts/uts_2017_sum_cs/C_Redact_rast/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
|
||||||
|
// Information about this assembly is defined by the following attributes.
|
||||||
|
// Change them to the values specific to your project.
|
||||||
|
|
||||||
|
[assembly: AssemblyTitle("C_Redact_rast")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("")]
|
||||||
|
[assembly: AssemblyCopyright("${AuthorCopyright}")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
|
||||||
|
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
|
||||||
|
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
|
||||||
|
|
||||||
|
[assembly: AssemblyVersion("1.0.*")]
|
||||||
|
|
||||||
|
// The following attributes are used to specify the signing key for the assembly,
|
||||||
|
// if desired. See the Mono documentation for more information about signing.
|
||||||
|
|
||||||
|
//[assembly: AssemblyDelaySign(false)]
|
||||||
|
//[assembly: AssemblyKeyFile("")]
|
||||||
2
uts/uts_2017_sum_cs/C_Redact_rast/distance.in
Normal file
2
uts/uts_2017_sum_cs/C_Redact_rast/distance.in
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
aba
|
||||||
|
baba
|
||||||
13
uts/uts_2017_sum_cs/aye/Program.cs
Normal file
13
uts/uts_2017_sum_cs/aye/Program.cs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace aye
|
||||||
|
{
|
||||||
|
class MainClass
|
||||||
|
{
|
||||||
|
public static void Main(string[] args)
|
||||||
|
{
|
||||||
|
#pragma
|
||||||
|
Console.WriteLine("Hello World!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
26
uts/uts_2017_sum_cs/aye/Properties/AssemblyInfo.cs
Normal file
26
uts/uts_2017_sum_cs/aye/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
|
||||||
|
// Information about this assembly is defined by the following attributes.
|
||||||
|
// Change them to the values specific to your project.
|
||||||
|
|
||||||
|
[assembly: AssemblyTitle("aye")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("")]
|
||||||
|
[assembly: AssemblyCopyright("${AuthorCopyright}")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
|
||||||
|
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
|
||||||
|
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
|
||||||
|
|
||||||
|
[assembly: AssemblyVersion("1.0.*")]
|
||||||
|
|
||||||
|
// The following attributes are used to specify the signing key for the assembly,
|
||||||
|
// if desired. See the Mono documentation for more information about signing.
|
||||||
|
|
||||||
|
//[assembly: AssemblyDelaySign(false)]
|
||||||
|
//[assembly: AssemblyKeyFile("")]
|
||||||
39
uts/uts_2017_sum_cs/aye/aye.csproj
Normal file
39
uts/uts_2017_sum_cs/aye/aye.csproj
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
|
||||||
|
<ProjectGuid>{0C75C0DD-FEC4-4DE3-BB42-2BB9C2AE5C86}</ProjectGuid>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<RootNamespace>aye</RootNamespace>
|
||||||
|
<AssemblyName>aye</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<ExternalConsole>true</ExternalConsole>
|
||||||
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release</OutputPath>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<ExternalConsole>true</ExternalConsole>
|
||||||
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="System" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="Program.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||||
|
</Project>
|
||||||
23
uts/uts_2017_sum_cs/uts_2017_sum.sln
Normal file
23
uts/uts_2017_sum_cs/uts_2017_sum.sln
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio 2012
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "C_Redact_rast", "C_Redact_rast\C_Redact_rast.csproj", "{1E8CCFCD-A327-4E5F-AE82-147D361DAEAF}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "aye", "aye\aye.csproj", "{0C75C0DD-FEC4-4DE3-BB42-2BB9C2AE5C86}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|x86 = Debug|x86
|
||||||
|
Release|x86 = Release|x86
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{1E8CCFCD-A327-4E5F-AE82-147D361DAEAF}.Debug|x86.ActiveCfg = Debug|x86
|
||||||
|
{1E8CCFCD-A327-4E5F-AE82-147D361DAEAF}.Debug|x86.Build.0 = Debug|x86
|
||||||
|
{1E8CCFCD-A327-4E5F-AE82-147D361DAEAF}.Release|x86.ActiveCfg = Release|x86
|
||||||
|
{1E8CCFCD-A327-4E5F-AE82-147D361DAEAF}.Release|x86.Build.0 = Release|x86
|
||||||
|
{0C75C0DD-FEC4-4DE3-BB42-2BB9C2AE5C86}.Debug|x86.ActiveCfg = Debug|x86
|
||||||
|
{0C75C0DD-FEC4-4DE3-BB42-2BB9C2AE5C86}.Debug|x86.Build.0 = Debug|x86
|
||||||
|
{0C75C0DD-FEC4-4DE3-BB42-2BB9C2AE5C86}.Release|x86.ActiveCfg = Release|x86
|
||||||
|
{0C75C0DD-FEC4-4DE3-BB42-2BB9C2AE5C86}.Release|x86.Build.0 = Release|x86
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
14
uts/uts_2017_sum_cs/uts_2017_sum.userprefs
Normal file
14
uts/uts_2017_sum_cs/uts_2017_sum.userprefs
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
<Properties StartupConfiguration="{1E8CCFCD-A327-4E5F-AE82-147D361DAEAF}|Default">
|
||||||
|
<MonoDevelop.Ide.Workbench ActiveDocument="aye/Program.cs">
|
||||||
|
<Files>
|
||||||
|
<File FileName="aye/Program.cs" Line="9" Column="9" />
|
||||||
|
</Files>
|
||||||
|
</MonoDevelop.Ide.Workbench>
|
||||||
|
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug|x86" />
|
||||||
|
<MonoDevelop.Ide.ItemProperties.C__Redact__rast PreferredExecutionTarget="MonoDevelop.Default" />
|
||||||
|
<MonoDevelop.Ide.DebuggingService.Breakpoints>
|
||||||
|
<BreakpointStore />
|
||||||
|
</MonoDevelop.Ide.DebuggingService.Breakpoints>
|
||||||
|
<MonoDevelop.Ide.DebuggingService.PinnedWatches />
|
||||||
|
<MultiItemStartupConfigurations />
|
||||||
|
</Properties>
|
||||||
180
uts/uts_2017_sum_py/1/RAW.py
Normal file
180
uts/uts_2017_sum_py/1/RAW.py
Normal file
@@ -0,0 +1,180 @@
|
|||||||
|
#RZ2T(CAM)_7.py:
|
||||||
|
import sys
|
||||||
|
|
||||||
|
sys.stdin = open('input.txt', 'r')
|
||||||
|
sys.stdout = open('output.txt', 'w')
|
||||||
|
|
||||||
|
n = int(input())
|
||||||
|
a = list(map(int, input().split()))
|
||||||
|
t = int(input())
|
||||||
|
|
||||||
|
a.sort()
|
||||||
|
u, y = 0, 0
|
||||||
|
for i in range(t):
|
||||||
|
x = list(map(int, input().split()))
|
||||||
|
if x[0] == 1:
|
||||||
|
u = u + 1
|
||||||
|
elif x[0] == 2:
|
||||||
|
y = y + x[1]
|
||||||
|
elif x[0] == 3:
|
||||||
|
q = y / u
|
||||||
|
d = n
|
||||||
|
for j in range(n):
|
||||||
|
if a[j] > q:
|
||||||
|
d = j
|
||||||
|
break
|
||||||
|
print(n - d)
|
||||||
|
|
||||||
|
sys.stdout.close()
|
||||||
|
|
||||||
|
#RZ2T(CAM)_8.py:
|
||||||
|
import sys
|
||||||
|
|
||||||
|
sys.stdin = open('input.txt', 'r')
|
||||||
|
sys.stdout = open('output.txt', 'w')
|
||||||
|
|
||||||
|
x = int(input())
|
||||||
|
a, b, c = list(map(int, input().split()))
|
||||||
|
z = [[a, 'a'], [b, 'b'], [c, 'c']]
|
||||||
|
z.sort()
|
||||||
|
c, b, a = z[0], z[1], z[2]
|
||||||
|
|
||||||
|
for i in range(int(x / a[0]) + 1):
|
||||||
|
for j in range(int((x - a[0]) / b[0]) + 1):
|
||||||
|
if (x - j * b[0] - i * a[0]) % c[0] == 0:
|
||||||
|
a[0], b[0], c[0] = i, j, (x - j * b[0] - i * a[0]) / c[0]
|
||||||
|
|
||||||
|
s = ''
|
||||||
|
for i in [a, b, c]:
|
||||||
|
if i[1] == 'a':
|
||||||
|
s = str(i[0])
|
||||||
|
|
||||||
|
for i in [a, b, c]:
|
||||||
|
if i[1] == 'b':
|
||||||
|
s = s + ' ' + str(i[0])
|
||||||
|
|
||||||
|
for i in [a, b, c]:
|
||||||
|
if i[1] == 'c':
|
||||||
|
s = s + ' ' + str(i[0])
|
||||||
|
|
||||||
|
print(s)
|
||||||
|
|
||||||
|
sys.stdout.close()
|
||||||
|
|
||||||
|
#RZ2T_7.py:
|
||||||
|
import sys
|
||||||
|
|
||||||
|
sys.stdin = open('input.txt', 'r')
|
||||||
|
sys.stdout = open('output.txt', 'w')
|
||||||
|
|
||||||
|
n, m = list(map(int, input().split()))
|
||||||
|
|
||||||
|
b = 0
|
||||||
|
for i in range(n):
|
||||||
|
a = list(map(int, input().split()))
|
||||||
|
c = 0
|
||||||
|
for j in a:
|
||||||
|
if j == 0:
|
||||||
|
c = c + 1
|
||||||
|
else:
|
||||||
|
b = max(b, c)
|
||||||
|
c = 0
|
||||||
|
b = max(b, c)
|
||||||
|
|
||||||
|
print(b)
|
||||||
|
|
||||||
|
sys.stdout.close()
|
||||||
|
|
||||||
|
#RZ2T_8.py:
|
||||||
|
import sys
|
||||||
|
|
||||||
|
sys.stdin = open('input.txt', 'r')
|
||||||
|
sys.stdout = open('output.txt', 'w')
|
||||||
|
|
||||||
|
n = int(input())
|
||||||
|
a = [list(map(int, input().split())) for i in range(n)]
|
||||||
|
sal = []
|
||||||
|
sup = []
|
||||||
|
mel = []
|
||||||
|
gar = []
|
||||||
|
for i in a:
|
||||||
|
sal.append(i[0])
|
||||||
|
sup.append(i[1])
|
||||||
|
mel.append(i[2])
|
||||||
|
gar.append(i[3])
|
||||||
|
from collections import Counter
|
||||||
|
|
||||||
|
print(Counter(sal).most_common(1)[0][0],
|
||||||
|
Counter(sup).most_common(1)[0][0],
|
||||||
|
Counter(mel).most_common(1)[0][0],
|
||||||
|
Counter(gar).most_common(1)[0][0])
|
||||||
|
|
||||||
|
#RZ2T_9.py:
|
||||||
|
import sys
|
||||||
|
|
||||||
|
sys.stdin = open('input.txt', 'r')
|
||||||
|
sys.stdout = open('output.txt', 'w')
|
||||||
|
|
||||||
|
n, m = list(map(int, input().split()))
|
||||||
|
a = []
|
||||||
|
for i in range(n):
|
||||||
|
a.append(list(map(int, input().split())))
|
||||||
|
|
||||||
|
def check(mas):
|
||||||
|
f = True
|
||||||
|
for i in range(len(mas)):
|
||||||
|
if mas[i] != mas[0]:
|
||||||
|
f = False
|
||||||
|
return f
|
||||||
|
|
||||||
|
|
||||||
|
for i in range(len(a)):
|
||||||
|
if not check(a[i]):
|
||||||
|
print('NO')
|
||||||
|
quit()
|
||||||
|
try:
|
||||||
|
slov = {}
|
||||||
|
pos = 0
|
||||||
|
last = a[pos][0]
|
||||||
|
slov[a[pos][0]] = 0
|
||||||
|
while a[pos][0] == last:
|
||||||
|
slov[a[pos][0]] += 1
|
||||||
|
last = a[pos][0]
|
||||||
|
pos += 1
|
||||||
|
last = a[pos][0]
|
||||||
|
###
|
||||||
|
try:
|
||||||
|
if slov[a[pos][0]]:
|
||||||
|
print('NO')
|
||||||
|
quit()
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
slov[a[pos][0]] = 0
|
||||||
|
while a[pos][0] == last:
|
||||||
|
slov[a[pos][0]] += 1
|
||||||
|
last = a[pos][0]
|
||||||
|
pos += 1
|
||||||
|
last = a[pos][0]
|
||||||
|
###
|
||||||
|
try:
|
||||||
|
if slov[a[pos][0]]:
|
||||||
|
print('NO')
|
||||||
|
quit()
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
slov[a[pos][0]] = 0
|
||||||
|
while len(a) != pos and a[pos][0] == last:
|
||||||
|
slov[a[pos][0]] += 1
|
||||||
|
last = a[pos][0]
|
||||||
|
pos += 1
|
||||||
|
las = -1
|
||||||
|
for i in slov:
|
||||||
|
if las == -1:
|
||||||
|
las = slov[i]
|
||||||
|
elif las != slov[i]:
|
||||||
|
print('NO')
|
||||||
|
quit()
|
||||||
|
except Exception:
|
||||||
|
print('NO')
|
||||||
|
quit()
|
||||||
|
print('YES')
|
||||||
21
uts/uts_2017_sum_py/1/RZ2T_8.py
Normal file
21
uts/uts_2017_sum_py/1/RZ2T_8.py
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
import sys
|
||||||
|
|
||||||
|
sys.stdin = open('input.txt', 'r')
|
||||||
|
sys.stdout = open('output.txt', 'w')
|
||||||
|
|
||||||
|
n = int(input())
|
||||||
|
a = [list(map(int, input().split())) for i in range(n)]
|
||||||
|
sal = []
|
||||||
|
sup = []
|
||||||
|
mel = []
|
||||||
|
gar = []
|
||||||
|
for i in a:
|
||||||
|
sal.append(i[0])
|
||||||
|
sup.append(i[1])
|
||||||
|
mel.append(i[2])
|
||||||
|
gar.append(i[3])
|
||||||
|
from collections import Counter
|
||||||
|
print(Counter(sal).most_common(1)[0][0],
|
||||||
|
Counter(sup).most_common(1)[0][0],
|
||||||
|
Counter(mel).most_common(1)[0][0],
|
||||||
|
Counter(gar).most_common(1)[0][0])
|
||||||
72
uts/uts_2017_sum_py/1/RZ2T_9.py
Normal file
72
uts/uts_2017_sum_py/1/RZ2T_9.py
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
import sys
|
||||||
|
|
||||||
|
sys.stdin = open('input.txt', 'r')
|
||||||
|
sys.stdout = open('output.txt', 'w')
|
||||||
|
|
||||||
|
n, m = list(map(int, input().split()))
|
||||||
|
a = []
|
||||||
|
for i in range(n):
|
||||||
|
a.append(list(map(int, input().split())))
|
||||||
|
|
||||||
|
#for i in range(len(a)):
|
||||||
|
# print(a[i])
|
||||||
|
|
||||||
|
def check(mas):
|
||||||
|
f = True
|
||||||
|
for i in range(len(mas)):
|
||||||
|
if mas[i] != mas[0]:
|
||||||
|
f = False
|
||||||
|
return f
|
||||||
|
|
||||||
|
for i in range(len(a)):
|
||||||
|
if not check(a[i]):
|
||||||
|
print('NO')
|
||||||
|
quit()
|
||||||
|
try:
|
||||||
|
slov = {}
|
||||||
|
pos = 0
|
||||||
|
last = a[pos][0]
|
||||||
|
slov[a[pos][0]] = 0
|
||||||
|
while a[pos][0] == last:
|
||||||
|
slov[a[pos][0]] += 1
|
||||||
|
last = a[pos][0]
|
||||||
|
pos += 1
|
||||||
|
last = a[pos][0]
|
||||||
|
###
|
||||||
|
try:
|
||||||
|
if slov[a[pos][0]]:
|
||||||
|
print('NO')
|
||||||
|
quit()
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
slov[a[pos][0]] = 0
|
||||||
|
while a[pos][0] == last:
|
||||||
|
slov[a[pos][0]] += 1
|
||||||
|
last = a[pos][0]
|
||||||
|
pos += 1
|
||||||
|
last = a[pos][0]
|
||||||
|
###
|
||||||
|
try:
|
||||||
|
if slov[a[pos][0]]:
|
||||||
|
print('NO')
|
||||||
|
quit()
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
slov[a[pos][0]] = 0
|
||||||
|
while len(a) != pos and a[pos][0] == last:
|
||||||
|
slov[a[pos][0]] += 1
|
||||||
|
last = a[pos][0]
|
||||||
|
pos += 1
|
||||||
|
|
||||||
|
#print(slov)
|
||||||
|
las = -1
|
||||||
|
for i in slov:
|
||||||
|
if las == -1:
|
||||||
|
las = slov[i]
|
||||||
|
elif las != slov[i]:
|
||||||
|
print('NO')
|
||||||
|
quit()
|
||||||
|
except Exception:
|
||||||
|
print('NO')
|
||||||
|
quit()
|
||||||
|
print('YES')
|
||||||
6
uts/uts_2017_sum_py/1/input.txt
Normal file
6
uts/uts_2017_sum_py/1/input.txt
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
5
|
||||||
|
1 1 3 2
|
||||||
|
1 3 2 2
|
||||||
|
2 2 2 2
|
||||||
|
1 4 4 3
|
||||||
|
2 1 1 2
|
||||||
55
uts/uts_2017_sum_py/2/RZ2T(SAM)_7.py
Normal file
55
uts/uts_2017_sum_py/2/RZ2T(SAM)_7.py
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
# RZ2T(SAM)_7.py
|
||||||
|
import sys
|
||||||
|
|
||||||
|
sys.stdin = open('input.txt', 'r')
|
||||||
|
sys.stdout = open('output.txt', 'w')
|
||||||
|
|
||||||
|
s = input()
|
||||||
|
a = []
|
||||||
|
for i in range(len(s)):
|
||||||
|
try:
|
||||||
|
if 1 <= int(s[i] + s[i+1]) <= 26:
|
||||||
|
a.append(int(s[i] + s[i+1]))
|
||||||
|
s = s[:i] + 'aa' + s[i+2:]
|
||||||
|
else:
|
||||||
|
raise Exception('No number')
|
||||||
|
except Exception:
|
||||||
|
try:
|
||||||
|
if int(s[i]):
|
||||||
|
a.append(int(s[i]))
|
||||||
|
s = s[:i] + 'a' + s[i + 1:]
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
s = ''
|
||||||
|
slov = {
|
||||||
|
1: 'z',
|
||||||
|
2: 'y',
|
||||||
|
3: 'x',
|
||||||
|
4: 'w',
|
||||||
|
5: 'v',
|
||||||
|
6: 'u',
|
||||||
|
7: 't',
|
||||||
|
8: 's',
|
||||||
|
9: 'r',
|
||||||
|
10: 'q',
|
||||||
|
11: 'p',
|
||||||
|
12: 'o',
|
||||||
|
13: 'n',
|
||||||
|
14: 'm',
|
||||||
|
15: 'l',
|
||||||
|
16: 'k',
|
||||||
|
17: 'j',
|
||||||
|
18: 'i',
|
||||||
|
19: 'h',
|
||||||
|
20: 'g',
|
||||||
|
21: 'f',
|
||||||
|
22: 'e',
|
||||||
|
23: 'd',
|
||||||
|
24: 'c',
|
||||||
|
25: 'b',
|
||||||
|
26: 'a',
|
||||||
|
}
|
||||||
|
for i in a:
|
||||||
|
s += slov[i]
|
||||||
|
print(s)
|
||||||
|
# ------------------------------------------ #
|
||||||
29
uts/uts_2017_sum_py/2/RZ2T(SAM)_8.py
Normal file
29
uts/uts_2017_sum_py/2/RZ2T(SAM)_8.py
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
# RZ2T(SAM)_8.py
|
||||||
|
import sys
|
||||||
|
|
||||||
|
sys.stdin = open('input.txt', 'r')
|
||||||
|
sys.stdout = open('output.txt', 'w')
|
||||||
|
|
||||||
|
n = int(input())
|
||||||
|
a = list(map(int, input().split()))
|
||||||
|
|
||||||
|
counter_ros = 0
|
||||||
|
counter_vio = 0
|
||||||
|
ros = []
|
||||||
|
vio = []
|
||||||
|
|
||||||
|
for i in range(1, n+1):
|
||||||
|
if a[i-1] == i % 2:
|
||||||
|
if i % 2 == 0:
|
||||||
|
ros.append(i-1)
|
||||||
|
counter_ros += 1
|
||||||
|
else:
|
||||||
|
vio.append(i-1)
|
||||||
|
counter_vio += 1
|
||||||
|
if counter_vio == counter_ros:
|
||||||
|
print(counter_ros)
|
||||||
|
for i in range(counter_ros):
|
||||||
|
print(ros[i]+1, ' ', vio[i]+1)
|
||||||
|
else:
|
||||||
|
print(-1)
|
||||||
|
# ------------------------------------------ #
|
||||||
14
uts/uts_2017_sum_py/2/ads.py
Normal file
14
uts/uts_2017_sum_py/2/ads.py
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
import sys
|
||||||
|
|
||||||
|
sys.stdin = open('input.txt', 'r')
|
||||||
|
#sys.stdout = open('output.txt', 'w')
|
||||||
|
a = []
|
||||||
|
try:
|
||||||
|
while True:
|
||||||
|
a.append(int(input()))
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
|
a.sort()
|
||||||
|
print(a[0])
|
||||||
|
print(a[len(a)-1])
|
||||||
29
uts/uts_2017_sum_py/2/das
Normal file
29
uts/uts_2017_sum_py/2/das
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
begin
|
||||||
|
var n := ReadInteger();
|
||||||
|
var roses := new integer[n];
|
||||||
|
var count_roses := 0;
|
||||||
|
var violets := new integer[n];
|
||||||
|
var count_violets := 0;
|
||||||
|
for var i := 1 to n do
|
||||||
|
begin
|
||||||
|
if ReadInteger() = i mod 2 then
|
||||||
|
if i mod 2 = 0 then
|
||||||
|
begin
|
||||||
|
roses[count_roses] := i;
|
||||||
|
inc(count_roses);
|
||||||
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
violets[count_violets] := i;
|
||||||
|
inc(count_violets);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
if count_roses = count_violets then
|
||||||
|
begin
|
||||||
|
writeln(count_roses);
|
||||||
|
for var i := 0 to count_roses - 1 do
|
||||||
|
println(roses[i], violets[i]);
|
||||||
|
end
|
||||||
|
else
|
||||||
|
write(-1)
|
||||||
|
end.
|
||||||
16
uts/uts_2017_sum_py/2/input.txt
Normal file
16
uts/uts_2017_sum_py/2/input.txt
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
160
|
||||||
|
160
|
||||||
|
185
|
||||||
|
170
|
||||||
|
160
|
||||||
|
130
|
||||||
|
110
|
||||||
|
170
|
||||||
|
190
|
||||||
|
160
|
||||||
|
160
|
||||||
|
130
|
||||||
|
190
|
||||||
|
145
|
||||||
|
210
|
||||||
|
130
|
||||||
40
uts/uts_2017_sum_py/3/A.py
Normal file
40
uts/uts_2017_sum_py/3/A.py
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
import sys
|
||||||
|
import itertools
|
||||||
|
sys.stdin = open('balls.in', 'r')
|
||||||
|
#sys.stdout = open('balls.out', 'w')
|
||||||
|
|
||||||
|
n = int(input())
|
||||||
|
query = [int(input()) for i in range(n)]
|
||||||
|
'''
|
||||||
|
yadra = [0]
|
||||||
|
count = 0
|
||||||
|
storona = 2
|
||||||
|
while count <= 300000:
|
||||||
|
sum = 0
|
||||||
|
for i in range(storona):
|
||||||
|
sum += i
|
||||||
|
storona += 1
|
||||||
|
count += sum
|
||||||
|
yadra.append(sum + yadra[-1])
|
||||||
|
|
||||||
|
print(yadra)
|
||||||
|
yadra.pop(0)
|
||||||
|
'''
|
||||||
|
yadra = [1, 4, 10, 20, 35, 56, 84, 120, 165, 220, 286, 364, 455, 560, 680, 816, 969, 1140, 1330, 1540, 1771, 2024, 2300, 2600, 2925, 3276, 3654, 4060, 4495, 4960, 5456, 5984, 6545, 7140, 7770, 8436, 9139, 9880, 10660, 11480, 12341, 13244, 14190, 15180, 16215, 17296, 18424, 19600, 20825, 22100, 23426, 24804, 26235, 27720, 29260, 30856, 32509, 34220, 35990, 37820, 39711, 41664, 43680, 45760, 47905, 50116, 52394, 54740, 57155, 59640, 62196, 64824, 67525, 70300, 73150, 76076, 79079, 82160, 85320, 88560, 91881, 95284, 98770, 102340, 105995, 109736, 113564, 117480, 121485, 125580, 129766, 134044, 138415, 142880, 147440, 152096, 156849, 161700, 166650, 171700, 176851, 182104, 187460, 192920, 198485, 204156, 209934, 215820, 221815, 227920, 234136, 240464, 246905, 253460, 260130, 266916, 273819, 280840, 287980, 295240, 302621]
|
||||||
|
|
||||||
|
for coun in query:
|
||||||
|
count = coun
|
||||||
|
counter = 0
|
||||||
|
index = 0
|
||||||
|
while yadra[index + 1] <= count:
|
||||||
|
index += 1
|
||||||
|
late = yadra[:index+1]
|
||||||
|
combs = 1
|
||||||
|
flag = True
|
||||||
|
while flag:
|
||||||
|
for i in itertools.combinations_with_replacement(late, combs):
|
||||||
|
if count - sum(i) == 0:
|
||||||
|
print(combs)
|
||||||
|
flag = False
|
||||||
|
break
|
||||||
|
combs += 1
|
||||||
17
uts/uts_2017_sum_py/3/B.py
Normal file
17
uts/uts_2017_sum_py/3/B.py
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import sys
|
||||||
|
|
||||||
|
sys.stdin = open('count.in', 'r')
|
||||||
|
sys.stdout = open('count.out', 'w')
|
||||||
|
|
||||||
|
m, n = list(map(int, input().split()))
|
||||||
|
x = [[0 for i in range(31)] for j in range(31)]
|
||||||
|
s = 0
|
||||||
|
for i in range(31):
|
||||||
|
x[1][i] = 1
|
||||||
|
for i in range(2, m+1):
|
||||||
|
for j in range(n+1):
|
||||||
|
for k in range(j+1):
|
||||||
|
x[i][j] += x[i-1][k]
|
||||||
|
for i in range(n+1):
|
||||||
|
s += x[m][i]
|
||||||
|
print(s)
|
||||||
6
uts/uts_2017_sum_py/3/balls.in
Normal file
6
uts/uts_2017_sum_py/3/balls.in
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
5
|
||||||
|
1
|
||||||
|
5
|
||||||
|
9
|
||||||
|
15
|
||||||
|
91
|
||||||
1
uts/uts_2017_sum_py/3/count.in
Normal file
1
uts/uts_2017_sum_py/3/count.in
Normal file
@@ -0,0 +1 @@
|
|||||||
|
3 5
|
||||||
24
uts/uts_2017_sum_py/5/C.py
Normal file
24
uts/uts_2017_sum_py/5/C.py
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
#import sys
|
||||||
|
|
||||||
|
#sys.stdin = open('rectangles.in', 'r')
|
||||||
|
#sys.stdout = open('rectangles.out', 'w')
|
||||||
|
n, m, k = map(int, input().split())
|
||||||
|
a = [[100000, 0, 100000, 0] for i in range(k)]
|
||||||
|
field = []
|
||||||
|
|
||||||
|
for i in range(n):
|
||||||
|
field.append(list(map(int, input().split())))
|
||||||
|
|
||||||
|
field.reverse()
|
||||||
|
|
||||||
|
for i in range(n):
|
||||||
|
for j in range(m):
|
||||||
|
if field[i][j] > 0:
|
||||||
|
v = field[i][j] - 1
|
||||||
|
a[v][0] = min(a[v][0], j)
|
||||||
|
a[v][1] = max(a[v][1], j)
|
||||||
|
a[v][2] = min(a[v][2], i)
|
||||||
|
a[v][3] = max(a[v][3], i)
|
||||||
|
|
||||||
|
for i in range(k):
|
||||||
|
print(a[i][0], a[i][2], a[i][1] + 1, a[i][3] + 1)
|
||||||
34
uts/uts_2017_sum_py/5/D.py
Normal file
34
uts/uts_2017_sum_py/5/D.py
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
import sys
|
||||||
|
|
||||||
|
sys.stdin = open('robot.in', 'r')
|
||||||
|
s = input()
|
||||||
|
|
||||||
|
d = 0
|
||||||
|
a = []
|
||||||
|
f = 0
|
||||||
|
c = 0
|
||||||
|
x = 0
|
||||||
|
y = 0
|
||||||
|
for i in s:
|
||||||
|
if i == 'S':
|
||||||
|
if (x, y) in a:
|
||||||
|
print(c)
|
||||||
|
exit()
|
||||||
|
a.append((x, y))
|
||||||
|
c += 1
|
||||||
|
if d == 0:
|
||||||
|
x += 1
|
||||||
|
if d == 1:
|
||||||
|
y += 1
|
||||||
|
if d == 2:
|
||||||
|
x -= 1
|
||||||
|
if d == 3:
|
||||||
|
y -= 1
|
||||||
|
if i == 'L':
|
||||||
|
d = (d + 1) % 4
|
||||||
|
if i == 'R':
|
||||||
|
d = (d - 1) % 4
|
||||||
|
if (x, y) in a:
|
||||||
|
print(c)
|
||||||
|
else:
|
||||||
|
print(-1)
|
||||||
5
uts/uts_2017_sum_py/5/rectangles.in
Normal file
5
uts/uts_2017_sum_py/5/rectangles.in
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
4 5 2
|
||||||
|
0 2 2 2 2
|
||||||
|
0 2 2 2 2
|
||||||
|
1 1 2 2 2
|
||||||
|
1 1 0 0 0
|
||||||
1
uts/uts_2017_sum_py/5/robot.in
Normal file
1
uts/uts_2017_sum_py/5/robot.in
Normal file
@@ -0,0 +1 @@
|
|||||||
|
RSSSSLSLSSLS
|
||||||
BIN
uts/uts_2k17_march_py/DER/A
Executable file
BIN
uts/uts_2k17_march_py/DER/A
Executable file
Binary file not shown.
75
uts/uts_2k17_march_py/DER/A.cpp
Normal file
75
uts/uts_2k17_march_py/DER/A.cpp
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <fstream>
|
||||||
|
#include <algorithm>
|
||||||
|
using namespace std;
|
||||||
|
#define MAXN 100007
|
||||||
|
|
||||||
|
int a[MAXN], tree[4 * MAXN], upd[4 * MAXN], n;
|
||||||
|
|
||||||
|
void build_tree(int v, int tl, int tr)
|
||||||
|
{
|
||||||
|
if(tl == tr) tree[v] = a[tl];
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int tm = (tl + tr) >> 1;
|
||||||
|
build_tree(v + v, tl, tm);
|
||||||
|
build_tree(v + v + 1, tm + 1, tr);
|
||||||
|
tree[v] = tree[v + v] + tree[v + v + 1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int query_tree(int v, int tl, int tr, int l, int r)
|
||||||
|
{
|
||||||
|
if(l > r) return 0;
|
||||||
|
if(upd[v] != -1) return upd[v] * (r - l + 1);
|
||||||
|
if(l == tl && r == tr) return tree[v];
|
||||||
|
int tm = (tl + tr) >> 1;
|
||||||
|
return query_tree(v + v, tl, tm, l, min(r, tm)) + query_tree(v + v + 1, tm + 1, tr, max(l, tm + 1), r);
|
||||||
|
}
|
||||||
|
|
||||||
|
void update_tree(int v, int tl, int tr, int l, int r, int color)
|
||||||
|
{
|
||||||
|
if(l > r) return;
|
||||||
|
if(l == tl && tr == r)
|
||||||
|
{
|
||||||
|
upd[v] = color;
|
||||||
|
tree[v] = color * (r - l + 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
upd[v] = -1;
|
||||||
|
int tm = (tl + tr) >> 1;
|
||||||
|
update_tree(v + v, tl, tm, l, min(r, tm), color);
|
||||||
|
update_tree(v + v + 1, tm + 1, tr, max(l, tm + 1), r, color);
|
||||||
|
tree[v] = tree[v + v] + tree[v + v + 1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
ifstream cin("sum.in");
|
||||||
|
ofstream cout("sum.out");
|
||||||
|
int k;
|
||||||
|
cin >> n >> k;
|
||||||
|
for(int i = 0; i < 4 * MAXN; i++) upd[i] = -1; //Изначально все отрезки(вершины) не обновлены
|
||||||
|
build_tree(1, 0, n-1);
|
||||||
|
int q, x, l, r;
|
||||||
|
char type;
|
||||||
|
scanf("%d", &q);
|
||||||
|
for(int i = 0; i < k; i++)
|
||||||
|
{
|
||||||
|
cin >> type;
|
||||||
|
cin >> l;
|
||||||
|
cin >> r;
|
||||||
|
if(type == 'Q')
|
||||||
|
{
|
||||||
|
printf("%d\n", query_tree(1, 0, n - 1, l, r));
|
||||||
|
}
|
||||||
|
else if(type == 'A')
|
||||||
|
{
|
||||||
|
update_tree(1, 0, n - 1, l, l, r);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
42
uts/uts_2k17_march_py/DER/A.py
Normal file
42
uts/uts_2k17_march_py/DER/A.py
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
import sys
|
||||||
|
problem_name = str('sum')
|
||||||
|
sys.stdin = open(problem_name + ".in", "r")
|
||||||
|
#sys.stdout = open(problem_name+".out", "w")
|
||||||
|
|
||||||
|
def deld(a):
|
||||||
|
left = len(a) // 2
|
||||||
|
right = len(a) // 2 + len(a) % 2
|
||||||
|
print(0, ' ', left, ' ', right, ' ', left+right)
|
||||||
|
b = [a[i] for i in range(left)]
|
||||||
|
c = [a[i] for i in range(left, left+right)]
|
||||||
|
return b, c
|
||||||
|
|
||||||
|
def build(a, fab):
|
||||||
|
if len(a) <= 1:
|
||||||
|
return
|
||||||
|
left, right = deld(a)
|
||||||
|
fab.append([0])
|
||||||
|
fab.append([0])
|
||||||
|
build(left, fab[0])
|
||||||
|
build(right, fab[1])
|
||||||
|
|
||||||
|
def build_linkers(a, fab):
|
||||||
|
|
||||||
|
|
||||||
|
n, k = list(map(int, input().split()))
|
||||||
|
mas = [[0] for i in range(n)]
|
||||||
|
fab = []
|
||||||
|
build(mas, fab)
|
||||||
|
query = []
|
||||||
|
for i in range(k-1):
|
||||||
|
s = input().split()
|
||||||
|
s[1] = int(s[1])-1
|
||||||
|
s[2] = int(s[2])
|
||||||
|
if s[0] == 'A':
|
||||||
|
mas[s[1]] = [s[2]]
|
||||||
|
else:
|
||||||
|
query.append(s)
|
||||||
|
|
||||||
|
print(query)
|
||||||
|
print(mas)
|
||||||
|
print(fab)
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user