CSP题解|202309-2 坐标变换(其二)|80分
#include <bits/stdc++.h> using namespace std; class point{ public: double x; double y; point(double x,double y){ this->x = x; this->y = y; } point(){ x=0;y=0; } void multiply(double k){ this->x*=k; this->y*=k; } void rotate(double k){ double tempX=x,tempY=y; x = tempX*cos(k)-tempY*sin(k); y = tempX*sin(k)+tempY*cos(k); } void say(){ cout<<fixed<<setprecision(3)<<x<<" "<<fixed<<setprecision(3)<<y<<endl; } }; class change{ public: int type; double data; change(){ type=0; data=0; } change(int i, double d){ type=i; data=d; } }; int main() { int opNum,queryNum; cin>>opNum>>queryNum; vector<change>ops; for(int i =0;i<opNum;i++){ int type;double d; cin>>type>>d; change c(type,d); ops.push_back(c); } //开始输入操作数起始结尾和坐标 while(queryNum--){ int beginNum,endNum;double x,y; cin>>beginNum>>endNum>>x>>y; beginNum--;endNum--; point p(x,y); for(int i =beginNum;i<=endNum;i++){ if(ops[i].type == 1){ p.multiply(ops[i].data); }else{ p.rotate(ops[i].data); } } p.say(); } }
80分,超时了...