Все задачи на 5.10.17 13:00
This commit is contained in:
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
|
||||
Reference in New Issue
Block a user