In [ ]:
# ID:10000
a, b = map(int, input().split())
print(a + b)
In [ ]:
# ID:10001
a = list(map(int, input().split()))
b = int(input())
sum = 0
for i in a:
if b+30 >= i:
sum+=1
print(sum)
In [ ]:
# ID:10003
list_a = []
list_b = []
max = 0
day = 1
for i in range(7):
a, b = map(int, input().split())
list_a.append(a)
list_b.append(b)
for i in range(7):
if max < list_a[i] + list_b[i]:
max = list_a[i] + list_b[i]
day = (i+1)
print(day)
In [ ]:
# ID:10004
book = [0 for i in range(1000)]
sum = 0
n = int(input())
nums = list(map(int, input().split()))
for i in range(n):
if book[nums[i]] == 0:
book[nums[i]] = nums[i]
sum += 1
print(sum)
for i in range(1000):
if book[i] != 0:
print(book[i], end=' ')
print()
In [ ]:
# ID:10009
s = input()
z = s[::-1]
ret = ''
if s[0] == '-':
z = s[1::]
# 进行反转
z = z[::-1]
ret = '-'
else:
ret = ''
bool_start_0 = True
for i in range(len(z)):
if z[i] != '0':
if bool_start_0 == True:
bool_start_0 = False
ret += z[i]
else:
if bool_start_0 == False:
ret += z[i]
print(ret)
In [ ]:
# ID:10011
In [ ]:
# ID:12034
# 求解炸弹人
# 输入n,m,起始坐标
n, m, startx, starty = map(int, input().split())
# 初始化数组
func bfs():
pass
In [ ]:
# ID:12033
# 炸弹人
n, m = map(int, input().split())
# a = list(map(str, input().split(' ')))
a = []
for i in range(n):
a.append(list(map(str, input())))
max = 0
sum = 0
x = 0
y = 0
p = 0
q = 0
for i in range(n):
for j in range(m):
if a[i][j] == '.':
sum = 0
x = i
y = j
while a[x][y] != '#':
if a[x][y] == 'G':
sum+=1
x-=1
x = i
y = j
while a[x][y] != '#':
if a[x][y] == 'G':
sum+=1
x+=1
x = i
y = j
while a[x][y] != '#':
if a[x][y] == 'G':
sum+=1
y-=1
x = i
y = j
while a[x][y] != '#':
if a[x][y] == 'G':
sum+=1
y+=1
if sum > max:
max = sum
print(max)
In [ ]:
# ID:12026
# 火柴棒等式
sum = 0
a = [6,2,5,5,4,5,6,3,7,6]
n = int(input())
def func(x):
m = 0
while x//10 != 0:
m += a[x%10]
x = x//10
m += a[x]
return m
for i in range(1111):
for j in range(1111):
c = i + j
if func(i) + func(j) + func(c) + 4 == n:
sum += 1
print(sum)
In [ ]:
# ID:12031
# 全排列
a = [0,0,0,0,0,0,0,0,0,0]
book = [0,0,0,0,0,0,0,0,0,0]
n = int(input())
def dfs(step):
if step == n+1:
for i in range(1, n+1):
print(a[i], end='')
print('')
return
for i in range(1, n+1):
if book[i] == 0:
book[i] = 1
a[step] = i
dfs(step+1)
book[i] = 0
dfs(1)
In [139]:
# enum.Enum 枚举类型
from collections import namedtuple
from enum import Enum
class Sort(Enum):
ASC = 1 # 升序
DESC = 2 # 降序
# 快速排序
def swap(L, a, b):
tmp = L[a]
L[a]= L[b]
L[b] = tmp
def qSrot(L, key, low, high):
if low >= high:
return
tmp = L[low];
left = low
right = high
while left < right:
while right > left and L[right][key] >= tmp[key]:
right -= 1
while left < right and L[left][key] <= tmp[key]:
left += 1
if left < right:
swap(L, left, right)
if low != left:
swap(L, left, low)
qSrot(L, key, low, left-1)
qSrot(L, key, left+1, high)
def quick_sort(L, key, sort=Sort.ASC):
lenList = len(L) - 1
qSrot(a_list, key ,0 ,lenList)
if sort == Sort.DESC:
L.reverse()
a_list = []
a_list.append({'name':'dd','price':32.00})
a_list.append({'name':'cc','price':40.00})
a_list.append({'name':'aa','price':12.00})
a_list.append({'name':'ff','price':8.00})
after_sort = quick_sort(a_list, 'price', sort=Sort.ASC)
print(a_list)
In [106]:
a = []
if a:
print("false")
In [ ]: