Codeforces 400C Inna and Huge Candy Matrix 【模拟】
2016-03-21 23:47
477 查看
题目链接:Codeforces 400C Inna and Huge Candy Matrix
题意:给定矩阵中某些元素的位置,问经过x次顺时针旋转、y次水平旋转、z次逆时针旋转后元素的位置。
AC代码:
题意:给定矩阵中某些元素的位置,问经过x次顺时针旋转、y次水平旋转、z次逆时针旋转后元素的位置。
AC代码:
#include <iostream> #include <cstdio> #include <cstring> #include <cstdlib> #include <cmath> #include <algorithm> #include <vector> #include <queue> #include <map> #include <stack> #define PI acos(-1.0) #define CLR(a, b) memset(a, (b), sizeof(a)) #define fi first #define se second #define ll o<<1 #define rr o<<1|1 using namespace std; typedef long long LL; typedef pair<int, int> pii; const int MAXN = 500 + 10; const int pN = 1e6;// <= 10^7 const int INF = 0x3f3f3f3f; const int MOD = 1e9 + 7; void add(LL &x, LL y) { x += y; x %= MOD; } int u, v, n, m; void Solve(int x, int y, int z) { int row = n, cul = m; int nx, ny; for(int i = 1; i <= x; i++) { nx = v; ny = row - u + 1; u = nx; v = ny; swap(row, cul); //cout << u << " " << v << endl; } for(int i = 1; i <= y; i++) { nx = u; ny = cul - v + 1; u = nx; v = ny; } for(int i = 1; i <= z; i++) { nx = cul - v + 1; ny = u; u = nx; v = ny; swap(row, cul); } cout << u << " " << v << endl; } int main() { int x, y, z, p; cin >> n >> m >> x >> y >> z >> p; x %= 4; y %= 2; z %= 4; for(int i = 0; i < p; i++) { cin >> u >> v; Solve(x, y, z); } return 0; }
相关文章推荐
- Spring源码之ApplicationContext(八)消息广播
- NYOJ-214-单调递增子序列(二)
- 基于django写的一个blog系统
- Debian下交换ctrl与esc键映射
- leetcode:Find Median from Data Stream
- 【ML】ICML2015_Unsupervised Learning of Video Representations using LSTMs
- 知识点5:ln链接
- python正则表达式
- The project target (Android N (Preview)) was not properly loaded.
- csh(tcsh)
- PSP记录个人项目耗时情况
- 设计模式学习笔记——状态模式
- 工具类:拉伸一张图片(UIImage分类)
- 项目之RFID天线设计
- requests的content与text导致lxml的解析问题
- Spring源码之ApplicationContext(七)获取消息资源
- JAVA 基础 final关键字
- AndroidAutoLayout 屏幕适配
- Codeforces 400B Inna and New Matrix of Candies 【模拟】
- 图示aidl原理