注意:注释在测试CSP时应全部删除!!!
第一题:
# 键盘输入两个数以空格隔开,分别为n,m
n,m = map(int, input().split( ))
# 根据n值可以循环输入n行值,得到一个列表(操作数)
madenum = [list(map(int, input().split())) for _ in range(n)]
# 根据m值可以循环输入m行值,得到一个列表(初始数组)
initalnum = [list(map(int, input().split())) for _ in range(m)]
# 循环初始数组
for num1 in initalnum:
# 每个数组都全部进行操作行为
for madenum1 in madenum:
num1[0] += madenum1[0]
num1[1] += madenum1[1]
print(num1[0],num1[1])
第二题:
# 需要用到前缀和的思想
from math import cos,sin
n,m = map(int, input().split( ))
madenum = [list(map(float, input().split())) for _ in range(n)]
initalnum = [list(map(int, input().split())) for _ in range(m)]
# 前缀和(积):将n个操作数中的动作统计起来,拉伸为积,旋转为和
kdate = [1]
thedate = [0]
for j in range(n):
if madenum[j][0] == 1.0:
kdate.append(kdate[j]* madenum[j][1])
thedate.append(thedate[j])
else:
kdate.append(kdate[j])
thedate.append(thedate[j]+madenum[j][1])
# 将每个数进行操作:将i之前的操作给去除!!
for initalnum_num in initalnum:
num1 = initalnum_num[0:2]
num2:list = initalnum_num[2:4]
thenum = thedate[num1[1]]-(thedate[num1[0]-1])
knum = kdate[num1[1]]/(kdate[num1[0]-1])
num2[0] = num2[0] * knum
num2[1] = num2[1] * knum
# 这里注意要采用临时变量,因为横坐标和纵坐标变换时都包含了双方上一个的坐标
num3 = num2[0]
num4 = num2[1]
num2[0] = num3*cos(thenum) - num4*sin(thenum)
num2[1] = num3*sin(thenum) + num4*cos(thenum)
print(num2[0],num2[1])
第二题想要得到满分还是需要用到一些方法,简化计算,要不然服务器会运行超时!
标签:02,01,202309,num1,num2,thedate,initalnum,input,kdate From: https://blog.csdn.net/c2310572426/article/details/141123563