Все задачи на 5.10.17 13:00
This commit is contained in:
9
uts/uts_2k17_march_py/Dun/A.py
Normal file
9
uts/uts_2k17_march_py/Dun/A.py
Normal file
@@ -0,0 +1,9 @@
|
||||
import sys
|
||||
from math import factorial
|
||||
problem_name = str('combs')
|
||||
sys.stdin = open(problem_name + ".in", "r")
|
||||
#sys.stdout = open(problem_name+".out", "w")
|
||||
n, k = list(map(int, input().split()))
|
||||
print(int(factorial(n)/(factorial(k)*factorial(n-k))))
|
||||
f = open('safdsf')
|
||||
f.close()
|
||||
14
uts/uts_2k17_march_py/Dun/B.py
Normal file
14
uts/uts_2k17_march_py/Dun/B.py
Normal file
@@ -0,0 +1,14 @@
|
||||
import sys
|
||||
problem_name = str('slalom')
|
||||
sys.stdin = open(problem_name + ".in", "r")
|
||||
sys.stdout = open(problem_name+".out", "w")
|
||||
|
||||
n= int(input())
|
||||
a = []
|
||||
for i in range(n):
|
||||
a.append(list(map(int, input().split())))
|
||||
count=0
|
||||
for i in reversed(range(len(a)-1)):
|
||||
for j in range(len(a[i])):
|
||||
a[i][j] = a[i][j] + max(a[i+1][j], a[i+1][j+1])
|
||||
print(a[0][0])
|
||||
5
uts/uts_2k17_march_py/Dun/C.py
Normal file
5
uts/uts_2k17_march_py/Dun/C.py
Normal file
@@ -0,0 +1,5 @@
|
||||
import sys
|
||||
problem_name = str('mushroom')
|
||||
sys.stdin = open(problem_name + ".in", "r")
|
||||
sys.stdout = open(problem_name+".out", "w")
|
||||
|
||||
18
uts/uts_2k17_march_py/Dun/D.py
Normal file
18
uts/uts_2k17_march_py/Dun/D.py
Normal file
@@ -0,0 +1,18 @@
|
||||
import sys
|
||||
problem_name = str('field')
|
||||
sys.stdin = open(problem_name + ".in", "r")
|
||||
sys.stdout = open(problem_name+".out", "w")
|
||||
|
||||
n, m = map(int, input().split())
|
||||
a = []
|
||||
b = [[10**9] * n for i in range(m)]
|
||||
for i in range(m):
|
||||
a.append(list(map(int, input().split())))
|
||||
b[0][0] = 0
|
||||
for i in range(m):
|
||||
for j in range(n):
|
||||
if i - 1 >= 0:
|
||||
b[i][j] = abs(a[i][j] - a[i - 1][j]) + b[i - 1][j]
|
||||
if j - 1 >= 0:
|
||||
b[i][j] = min(b[i][j], b[i][j - 1] + abs(a[i][j] - a[i][j - 1]))
|
||||
print(b[m - 1][n - 1])
|
||||
22
uts/uts_2k17_march_py/Dun/E.py
Normal file
22
uts/uts_2k17_march_py/Dun/E.py
Normal file
@@ -0,0 +1,22 @@
|
||||
import sys
|
||||
problem_name = str('goat')
|
||||
sys.stdin = open(problem_name + ".in", "r")
|
||||
#sys.stdout = open(problem_name+".out", "w")
|
||||
|
||||
m, n, k = map(int, input(). split())
|
||||
T = [[False]*(n+1) for i in range(m+1)]
|
||||
for i in range(k):
|
||||
n, y = map(int, input().split())
|
||||
T[n - 1][y - 1] = True
|
||||
C = [[0]*(n+1) for i in range(m+1)]
|
||||
C[1][1] = 1
|
||||
dead = 0
|
||||
for i in range(1, m+1):
|
||||
for j in range(1, n+1):
|
||||
if i == 1 and j == 1:
|
||||
comb = 1
|
||||
else:
|
||||
comb = C[i-1][j] + C[i][j-1]
|
||||
if T[i][j]:
|
||||
dead += comb
|
||||
comb = 0
|
||||
9
uts/uts_2k17_march_py/Dun/H.py
Normal file
9
uts/uts_2k17_march_py/Dun/H.py
Normal file
@@ -0,0 +1,9 @@
|
||||
import sys
|
||||
import re
|
||||
problem_name = str('patterns')
|
||||
sys.stdin = open(problem_name + ".in", "r")
|
||||
sys.stdout = open(problem_name+".out", "w")
|
||||
if re.compile(input().replace('*', '.*').replace('?', '.')).match(input()) != None:
|
||||
print('YES')
|
||||
else:
|
||||
print('NO')
|
||||
1
uts/uts_2k17_march_py/Dun/combs.in
Normal file
1
uts/uts_2k17_march_py/Dun/combs.in
Normal file
@@ -0,0 +1 @@
|
||||
3 2
|
||||
3
uts/uts_2k17_march_py/Dun/field.in
Normal file
3
uts/uts_2k17_march_py/Dun/field.in
Normal file
@@ -0,0 +1,3 @@
|
||||
4 2
|
||||
1 2 3 5
|
||||
3 8 4 7
|
||||
5
uts/uts_2k17_march_py/Dun/goat.in
Normal file
5
uts/uts_2k17_march_py/Dun/goat.in
Normal file
@@ -0,0 +1,5 @@
|
||||
2 2 1
|
||||
1 2
|
||||
2 2 2
|
||||
1 2
|
||||
2 1
|
||||
6
uts/uts_2k17_march_py/Dun/mushroom.in
Normal file
6
uts/uts_2k17_march_py/Dun/mushroom.in
Normal file
@@ -0,0 +1,6 @@
|
||||
4 4 3 2
|
||||
1 4
|
||||
2 3
|
||||
4 3
|
||||
2 2
|
||||
3 4
|
||||
2
uts/uts_2k17_march_py/Dun/patterns.in
Normal file
2
uts/uts_2k17_march_py/Dun/patterns.in
Normal file
@@ -0,0 +1,2 @@
|
||||
k?t?n
|
||||
kitten
|
||||
5
uts/uts_2k17_march_py/Dun/slalom.in
Normal file
5
uts/uts_2k17_march_py/Dun/slalom.in
Normal file
@@ -0,0 +1,5 @@
|
||||
4
|
||||
1
|
||||
4 3
|
||||
5 6 7
|
||||
8 9 0 9
|
||||
Reference in New Issue
Block a user