代码如下:
#include <bits/stdc++.h>
using namespace std;
typedef pair<double, double> PDD; // first表示拉伸倍数, second表示旋转角度
const int N = 1e5 + 10;
PDD op[N]; // 前缀和数组
int n, m;
int main()
{
cin >> n >> m;
int a;
double b;
// 初始化op
op[0] = {1.0, 0};
// 处理前缀和数组
for(int i = 1; i <= n; i++ )
{
cin >> a >> b;
if(a == 1)
{
op[i].first = op[i - 1].first * b;
op[i].second = op[i - 1].second;
}
else if(a == 2)
{
op[i].second = op[i - 1].second + b;
op[i].first = op[i - 1].first;
}
}
int l, r;
double x, y;
double ext, ang;
for(int i = 0; i < m; i++ )
{
cin >> l >> r >> x >> y;
ext = op[r].first / op[l - 1].first;
ang = op[r].second - op[l - 1].second;
x *= ext;
y *= ext;
printf("%.3lf %.3lf\n", x * cos(ang) - y * sin(ang), x * sin(ang) + y * cos(ang));
}
return 0;
}