题目链接:http://codeforces.com/problemset/problem/400/C
题目大意:给出n,m,x,y,z,p,n*m的矩阵上有p块糖果,给出p块糖果的坐标,输出矩阵顺时针旋转x次,镜像翻转y次,逆时针旋转z次后糖果坐标。
题目分析:旋转完n和m要交换,翻转不用,旋转4次和翻转2次都是不变的。
顺时针旋转:
n=3, m=2
(1,1)->(1,3) (1,2)->(2,3)
(2,1)->(1,2) (2,2)->(2,2)
(3,1)->(1,1) (3,2)->(2,1)
得到规律:x'=y,y'=1+n-x
n=3, m=2
(1,1)->(1,2) (1,2)->(1,1)
(2,1)->(2,2) (2,2)->(2,1)
(3,1)->(3,2) (3,2)->(3,1)
得到规律:x'=x,y'=n-y
(1,1)->(2,1) (1,2)->(1,1)
(2,1)->(2,2) (2,2)->(1,2)
(3,1)->(2,3) (3,2)->(1,3)
得到规律:x'=m+1-y,y'=x
代码参考:
#include
#include
#include
#include
using namespace std;
const int N = 1e5+9;
struct Point
{
int x, y;
}pos[N];
int n, m, x, y, z, p;
void clockwise()
{
int x, y;
for(int i=0; i