watcc @ 2024-05-01 18:43:09
如何用PYTHON?
by watcc @ 2024-05-01 18:43:30
P1001 A+B Problem
by zhouzihang1 @ 2024-05-01 18:45:44
s = input().split()
print(int(s[0]) + int(s[1]))
by guoxinzhuo2012 @ 2024-05-01 18:49:08
让我看看有没有犇犇
by 编程小贝壳 @ 2024-05-01 19:37:42
一个比较简单的写法,splay树:
class Node:
def __init__(self, val):
self.val = val
self.left = None
self.right = None
self.parent = None
self.size = 1
self.sum = val
self.reverse = False
self.add_tag = 0
class SplayTree:
def __init__(self):
self.root = None
def push_up(self, node):
node.size = node.left.size + node.right.size + 1
node.sum = node.left.sum + node.right.sum + node.val
def rotate(self, x):
y = x.parent
z = y.parent
kind = x == y.right
if y == self.root:
self.root = x
else:
z.left = x if kind else y
x.parent = z
y.parent = x
y.left = x.right
x.right.parent = y if x.right else None
x.right = y
self.push_up(y)
self.push_up(x)
def splay(self, x):
while x != self.root:
y = x.parent
z = y.parent
if y != self.root:
if x == y.left and z.left == y or x == y.right and z.right == y:
self.rotate(y)
else:
self.rotate(x)
self.rotate(x)
def kth(self, k):
node = self.root
while True:
if k < node.left.size + 1:
node = node.left
elif k > node.left.size + 1:
k -= node.left.size + 1
node = node.right
else:
return node
def split(self, l, r):
x = self.kth(l)
y = self.kth(r + 2)
self.splay(x)
self.splay(y)
def reverse_range(self, l, r):
self.split(l, r)
self.root.right.left.reverse = not self.root.right.left.reverse
def add_range(self, l, r, v):
self.split(l, r)
self.root.right.left.add_tag += v
self.root.right.left.sum += v * self.root.right.left.size
def build(self, arr):
if not arr:
return None
mid = len(arr) // 2
node = Node(arr[mid])
node.left = self.build(arr[:mid])
node.right = self.build(arr[mid+1:])
if node.left:
node.left.parent = node
if node.right:
node.right.parent = node
self.push_up(node)
return node
splay = SplayTree()
splay.root = splay.build([1, 2, 3, 4, 5])
splay.reverse_range(1, 3)
splay.add_range(2, 4, 10)
可能有错,我还是太菜了
by hyh0174 @ 2024-05-14 21:57:45
@watcc
print(sum(map(int,input().split())))