codeforce 400 C
来源:互联网 发布:宁波php招聘 编辑:程序博客网 时间:2024/04/30 19:24
Inna and Dima decided to surprise Sereja. They brought a really huge candy matrix, it's big even for Sereja! Let's number the rows of the giant matrix from 1 to n from top to bottom and the columns — from 1 to m, from left to right. We'll represent the cell on the intersection of the i-th row and j-th column as (i, j). Just as is expected, some cells of the giant candy matrix contain candies. Overall the matrix hasp candies: the k-th candy is at cell (xk, yk).
The time moved closer to dinner and Inna was already going to eat p of her favourite sweets from the matrix, when suddenly Sereja (for the reason he didn't share with anyone) rotated the matrix x times clockwise by 90 degrees. Then he performed the horizontal rotate of the matrix y times. And then he rotated the matrix z times counterclockwise by 90 degrees. The figure below shows how the rotates of the matrix looks like.
Inna got really upset, but Duma suddenly understood two things: the candies didn't get damaged and he remembered which cells contained Inna's favourite sweets before Sereja's strange actions. Help guys to find the new coordinates in the candy matrix after the transformation Sereja made!
The first line of the input contains fix integers n, m, x, y, z, p (1 ≤ n, m ≤ 109; 0 ≤ x, y, z ≤ 109; 1 ≤ p ≤ 105).
Each of the following p lines contains two integers xk, yk (1 ≤ xk ≤ n; 1 ≤ yk ≤ m) — the initial coordinates of the k-th candy. Two candies can lie on the same cell.
For each of the p candies, print on a single line its space-separated new coordinates.
3 3 3 1 1 91 11 21 32 12 22 33 13 23 3
1 31 21 12 32 22 13 33 23 1
顺时针旋转一次(x,y)--->(y,n+1-x)
顺时针旋转二次(x,y)--->(n+1-x,m+1-y)
顺时针旋转三次(x,y)--->(m+1-y,x)
顺时针旋转四次(x,y)--->(x,y)
水平翻转一次(x,y)--->(x,m+1-y)
水平翻转一次(x,y)--->(x,y)
逆时针旋转一次(x,y)--->(m+1-y,x)
逆时针旋转二次(x,y)--->(n+1-x,m+1-y)
逆时针旋转三次(x,y)--->(y,n+1-x)
逆时针旋转四次(x,y)--->(x,y)
- codeforce 400 C
- Codeforce Round #400 C 签到题
- Codeforce # C. Average Score
- CodeForce 279C
- codeforce 237 C D
- Codeforce C. Barcode
- Codeforce 57C Array
- Codeforce 240C Practice
- Codeforce 332C
- codeforce 370C
- codeforce 6C
- codeforce 12C map
- codeforce 14C
- codeforce 18C
- codeforce 447C
- codeforce 20140808 C. Boredom
- codeforce 492 C D
- (288C)codeforce
- 通俗例子详解Thread.sleep()
- 数字读取
- Ubuntu 12.04(32位)安装Oracle 11g(32位)全过程以及几乎所有问题的解决办法
- [Linux]C语言遍历文件和目录
- MachineLearning(Andrew)Week1
- codeforce 400 C
- 二周 项目3 文件+结构体实现使用功能
- 静态数据成员
- linux下clang+llvm3.3安装(ubuntu)
- 对话框包含视类头文件出错
- java中多线程的实现方式有两种
- Logistic Function == Sigmoid Function
- 机构题成绩处理
- 动作栏——ActionBar(一)