codeforces C. Inna and Huge Candy Matrix
2015-02-01 19:16
351 查看
http://codeforces.com/problemset/problem/400/C
题意:给你一个n*m的矩阵,然后在矩阵中有p个糖果,给你每个糖果的初始位置,然后经过x次顺时针反转,y次旋转,z次逆时针反转,问最后每个糖果的位置。
思路:推出顺时针反转、旋转、逆时针反转的坐标的变化即可。
View Code
题意:给你一个n*m的矩阵,然后在矩阵中有p个糖果,给你每个糖果的初始位置,然后经过x次顺时针反转,y次旋转,z次逆时针反转,问最后每个糖果的位置。
思路:推出顺时针反转、旋转、逆时针反转的坐标的变化即可。
#include <cstdio> #include <cstring> #include <cmath> #include <iostream> #define maxn 100010 #include <algorithm> using namespace std; int n,m,x,y,z,k; struct node { int x,y; } p[maxn]; int main() { scanf("%d%d%d%d%d%d",&n,&m,&x,&y,&z,&k); for(int i=1; i<=k; i++) { scanf("%d%d",&p[i].x,&p[i].y); } x%=4; y%=2; z%=4; for(int i=1; i<=k; i++) { int nn=n,mm=m,xx,yy; for(int j=1; j<=x; j++) { xx=p[i].x; yy=p[i].y; p[i].x=yy; p[i].y=nn-xx+1; swap(nn,mm); } for(int j=1; j<=y; j++) { xx=p[i].x; yy=p[i].y; p[i].x=xx; p[i].y=mm-yy+1; } for(int j=1; j<=z; j++) { xx=p[i].x; yy=p[i].y; p[i].x=mm-yy+1; p[i].y=xx; swap(nn,mm); } } for(int i=1; i<=k; i++) { printf("%d %d\n",p[i].x,p[i].y); } return 0; }
View Code
相关文章推荐
- codeforces Inna and Huge Candy Matrix
- Codeforces 400C Inna and Huge Candy Matrix(模拟)
- (CF)C. Inna and Huge Candy Matrix
- Codeforces 400C Inna and Huge Candy Matrix 【模拟】
- codeforces 400C - Inna and Huge Candy Matrix
- C - Inna and Huge Candy Matrix
- CF 400C - Inna and Huge Candy Matrix
- codeforces 400C - Inna and Huge Candy Matrix(耐心找规律,细节还是要注意的)
- Codeforces 400C Inna and Huge Candy Matrix
- Codeforces 400B Inna and Huge Candy Matrix(模拟)
- codeforces 400C Inna and Huge Candy Matrix
- Codeforces Round #234 (Div. 2) B. Inna and New Matrix of Candies
- codeforces 400 C Inna and Huge Candy Matrix【模拟】
- Codeforces #229 D2C:Inna and Candy Boxes
- Codeforces #229 D2D: Inna and Sweet Matrix
- Codeforces 400 C. Inna and Huge Candy Matrix
- C. Inna and Huge Candy Matrix(cf)
- codeforces round #234B(DIV2) C Inna and Huge Candy Matrix
- Codeforces 400 C. Inna and Huge Candy Matrix【 Codeforces Round #234 (Div. 2)】
- Codeforces Round #229 (Div. 2) A. Inna and Alarm Clock