zoukankan      html  css  js  c++  java
  • Luogu P2129 L国的战斗续之多路出击 模拟

    诡异而冗长的名字下一般没什么难题

    坐标的本质是与原点的相对位置关系,所以改变全部坐标只要改变坐标系就好了。

     1 #include<iostream> 
     2 #include<cstdio>
     3 using namespace std;
     4 typedef long long ll;
     5 
     6 const ll Maxn = 5e5+10;
     7 
     8 ll x[Maxn],y[Maxn],ox,oy,xt,yt,n,m,p[Maxn],q[Maxn];
     9 char opt[Maxn];
    10 
    11 void read(ll& a){
    12     a = 0;char c = getchar(),l = c;
    13     while(c < '0'||c > '9')l = c,c = getchar();
    14     while('0' <= c&&c <= '9')a = a*10+c-'0',c = getchar();
    15     if(l == '-')a = -a;
    16 }
    17 
    18 void read(ll& a,ll& b){
    19     read(a),read(b);
    20 }
    21 
    22 int main(){
    23     xt = yt = 1,ox = oy = 0;
    24     read(n,m);
    25     for(ll i = 1;i <= n;i++)read(x[i],y[i]);
    26     for(int i = 1;i <= m;i++){
    27         cin >> opt[i];
    28         if(opt[i] == 'm')read(p[i],q[i]);
    29     }
    30     while(m){
    31         if(opt[m] == 'x')xt = -xt;
    32         else if(opt[m] == 'y')yt = -yt;
    33         else ox -= xt*p[m],oy -= yt*q[m];
    34         m--;
    35     }
    36     for(ll i = 1;i <= n;i++)printf("%lld %lld
    ",xt*(x[i]-ox),yt*(y[i]-oy));
    37 return 0;
    38 }
  • 相关阅读:
    Linux部署golang程序(无数据库访问)
    MySQL备份数据库mysqldump
    Linux命令netstat
    SQL优化01(转载)
    springcloud之gateway点滴
    关于数据库错误:serverTimeZone
    代码重构的重要性
    关于集合的泛型
    python 视频下载神器(you-get)
    linux下ssh
  • 原文地址:https://www.cnblogs.com/Wangsheng5/p/11783345.html
Copyright © 2011-2022 走看看