坐标变换(其一)
代码:
#include <bits/stdc++.h>
using namespace std;
int main(){
int n,m,x,y,sumx=0,sumy=0;
cin>>n>>m;
for(int i=1;i<=n;i++){
cin>>x>>y;
sumx+=x,sumy+=y;
}
for(int i=1;i<=m;i++){
cin>>x>>y;
cout<<x+sumx<<" "<<y+sumy<<endl;
}
return 0;
}
坐标变换(其二)
代码:
#include <bits/stdc++.h>
#define N 100005
using namespace std;
int n,m,op,l,r;
double x,y;
double pres[N],s,prek[N],k;//倍数和旋转度数的前缀和
int main(){
cin>>n>>m;
prek[0]=1;
for(int i=1;i<=n;i++){
cin>>op;
if(op==1){
cin>>k;
prek[i]=prek[i-1]*k;
pres[i]=pres[i-1];
}
else{
cin>>s;
prek[i]=prek[i-1];
pres[i]=pres[i-1]+s;
}
}
for(int i=1;i<=m;i++){
cin>>l>>r>>x>>y;
x*=(prek[r]/prek[l-1]);
y*=(prek[r]/prek[l-1]);
double px=x,py=y,s=pres[r]-pres[l-1];
x=px*cos(s)-py*sin(s);
y=px*sin(s)+py*cos(s);
printf("%.3lf %.3lf\n",x,y);
}
return 0;
}