AcWing 5298. 坐标变换(其二)
原题链接
简单
作者:
Tiscard
,
2024-03-30 09:32:42
,
所有人可见
,
阅读 16
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
const int N = 100010;
int n, m;
int sx, sy;
double ki[N], ce[N];
int main(){
scanf("%d %d", &n, &m);
ki[0] = 1;
for(int i = 1; i <= n; i ++){
ki[i] = 1;
int u;
scanf("%d", &u);
if(u == 1){
scanf("%lf", &ki[i]);
}else{
scanf("%lf", &ce[i]);
}
ki[i] *= ki[i - 1];
ce[i] = ce[i] + ce[i - 1];
}
while(m -- ){
double x, y;
int l, r;
scanf("%d %d %lf %lf", &l, &r, &x, &y);
double k, c;
k = ki[r] / ki[l - 1];
c = ce[r] - ce[l - 1];
x *= k;
y *= k;
double xx, yy;
xx = x * cos(c) - y * sin(c);
yy = x * sin(c) + y * cos(c);
printf("%lf %lf\n", xx, yy);
}
return 0;
}