题目链接http://codeforces.com/problemset/problem/400/C

题意:给出一个(N,M)矩形和矩形里的p(p<=1e5)个点坐标,然后顺时针旋转x,镜面对称y次,再逆时针旋转z次。然后输出p个点坐标。

题解:顺时针旋转x次与顺时针旋转x%4次的效果是一样的,同理逆时针。镜面对称y次和镜面对称y%2次的效果也是一样的。但是这个坐标系跟普通的坐标系不一样,是以原点的右边为y轴的正方向,原点的下方为x轴的正方向。而且每次进行逆时针、顺时针旋转的时候,(N,M)都要交换一下,因为每次旋转都会改变矩形的长和宽。

#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + ;
struct node
{
int x, y;
} E[maxn];
int N, M, x, y, z, p;
void turnx()
{
for(int i = ; i <= p; i++)
{
int t = N + - E[i].x;
E[i].x = E[i].y;
E[i].y = t;
}
swap(N, M);
}
void turny()
{
for(int i = ; i <= p; i++)
E[i].y = M + - E[i].y;
}
void turnz()
{
for(int i = ; i <= p; i++)
{
int t = M + - E[i].y;
E[i].y = E[i].x;
E[i].x = t;
}
swap(N, M);
}
int main ()
{
scanf("%d%d%d%d%d%d", &N, &M, &x, &y, &z, &p);
for(int i = ; i <= p; i++)
{
scanf("%d%d", &E[i].x, &E[i].y);
}
x %= ;
y %= ;
z %= ;
for(int i = ; i <= x; i++)
turnx();
if(y) turny();
for(int i = ; i <= z; i++)
turnz();
for(int i = ; i <= p; i++)
printf("%d %d\n", E[i].x, E[i].y);
return ;
}

最新文章

  1. Linux初识
  2. Compile FreeCAD on Windows
  3. 定制sqlmap tamper脚本
  4. JS 原型的妙用
  5. SPI总线
  6. perl array, scalar and hash
  7. Linux Bash 使用$?来防止一些误删操作
  8. cookie转CookieCollection
  9. 关于SWT常用组件(按钮,复选框,单选框(Button类))
  10. java web知识点总结
  11. Flashback Recovery Area的设置与取消
  12. js刷新页面不回到顶部
  13. 在64位系统下,指向int型的指针占的内存空间多大?
  14. 小甲鱼Python第二十二讲课后习题
  15. 科学计算和可视化(numpy及matplotlib学习笔记)
  16. [Golang] 开源一个帧同步服务器
  17. c#多线程与委托(转)
  18. JSON 简介
  19. angular的启动原理
  20. Spring系列(一):Spring的基本概念及其核心

热门文章

  1. H5多媒体
  2. 【BZOJ】3771: Triple FTT+生成函数
  3. phpmywind目录结构
  4. perl6 单线程破解phpmyadmin脚本
  5. http://www.onvif.org/onvif/ver20/util/operationIndex.html
  6. Repository.UpdateModel(model, db);
  7. 「caffe编译bug」 undefined reference to `boost::match_results&lt;__gnu_cxx::__normal_iterator&lt;char const*, std::__cxx11
  8. DroidParts 中文系列教程(基于官方教程)
  9. 【转载】移动开发中的上下左右滑动插件jquery.swipe.js
  10. hdu 1848(SG函数)