CF400C/[思维题]
2024-09-28 06:15:08
题目链接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 ;
}
最新文章
- Linux初识
- Compile FreeCAD on Windows
- 定制sqlmap tamper脚本
- JS 原型的妙用
- SPI总线
- perl array, scalar and hash
- Linux Bash 使用$?来防止一些误删操作
- cookie转CookieCollection
- 关于SWT常用组件(按钮,复选框,单选框(Button类))
- java web知识点总结
- Flashback Recovery Area的设置与取消
- js刷新页面不回到顶部
- 在64位系统下,指向int型的指针占的内存空间多大?
- 小甲鱼Python第二十二讲课后习题
- 科学计算和可视化(numpy及matplotlib学习笔记)
- [Golang] 开源一个帧同步服务器
- c#多线程与委托(转)
- JSON 简介
- angular的启动原理
- Spring系列(一):Spring的基本概念及其核心
热门文章
- H5多媒体
- 【BZOJ】3771: Triple FTT+生成函数
- phpmywind目录结构
- perl6 单线程破解phpmyadmin脚本
- http://www.onvif.org/onvif/ver20/util/operationIndex.html
- Repository.UpdateModel(model, db);
- 「caffe编译bug」 undefined reference to `boost::match_results<;__gnu_cxx::__normal_iterator<;char const*, std::__cxx11
- DroidParts 中文系列教程(基于官方教程)
- 【转载】移动开发中的上下左右滑动插件jquery.swipe.js
- hdu 1848(SG函数)