题解:需要将所有的前n次变换存储到对应的数组里,在第i-j次变换就直接数组相减即可。
// #pragma GCC optimize(2, 3, "Ofast", "inline")
#include <bits/stdc++.h>
// #define endl '\n'
using namespace std;
double k[100010];
double theta[100010];
void work()
{
int n,m;
scanf("%d%d",&n,&m);
memset(k,1,sizeof(k));
k[0]=1;
theta[0]=0;
int type;
double oper;
for(int i=1;i<=n;i++)
{
scanf("%d,%lf",&type,&oper);
if(type==1)
{
k[i]=k[i-1]*oper;
theta[i]=theta[i-1];
}
else
{
k[i]=k[i-1];
theta[i]=theta[i-1]+oper;
}
}
int i,j;
double x,y;
double deltak;
double deltatheta;
for(int q=0;q<m;q++)
{
scanf("%d %d %lf %lf",&i,&j,&x,&y);
deltak=k[j]/k[i-1];
deltatheta=theta[j]-theta[i-1];
double x1=x*deltak;
double y1=y*deltak;
x=x1*cos(deltatheta)-y1*sin(deltatheta);
y=x1*sin(deltatheta)+y1*cos(deltatheta);
// cout<<x<<" "<<y<<endl;
printf("%.3f %.3f\n",x,y);
}
}
int main()
{
// ios::sync_with_stdio(false);
// cin.tie(0);
// cout.tie(0);
work();
return 0;
}