策略:
只考虑存在拉伸操作的情况下,最终拉伸的系数等于每次拉伸操作系数的乘积。 只考虑存在旋转操作的情况下,最终旋转的角度等于每次旋转操作角度的和。
复习一下极坐标(ρ,θ)转换极坐标怎么与直角坐标系相互转化? - 知乎
import math
n,m=map(int,input().split())
op,lst2=[],[]#
for i in range(n):
opp,k=map(float,input().split())#
if opp==1:#拉伸操作
op.append([k, 0])#
else:
op.append([1, k])
for i in range(1, n):
#op存储拉伸操作的前缀积以及旋转操作的前缀和
op[i][0]*=op[i-1][0]
op[i][1]+=op[i-1][1]
for _ in range(m):
# i j x y:坐标 (x,y) 经过操作 ti,⋯,tj(1≤i≤j≤n)(看懂题目!!)后的新坐标
l,r,x,y=map(int,input().split())#l,r是指令起始和终止序号!
l,r=l-1,r-1#
#初始化极坐标
R=math.sqrt(x*x+y*y)
# 初始化角度!
theta=0
if x==0:
if y>0:
theta=math.pi/2
else:
theta=-math.pi/2
else:
theta=math.atan2(y,x)#
#一步到位,操作 1-r的所有操作,再撤销前1-(l-1)!!的
R*= op[r][0]
theta+=op[r][1]#
if l:
R/=op[l-1][0]#!
theta-=op[l-1][1]#
#恢复二维坐标
x,y=R*math.cos(theta),R*math.sin(theta)
lst2.append((x,y))
for i in lst2:
x,y=i[0],i[1]
print('{:.3f} {:.3f}'.format(x,y))