#A: P4924 [1007]魔法少女小Scarlet

这道题考了矩阵旋转

其实很考验推公式的能力和代码能力

这里有个小技巧

可以设(x, y)为原点,然后去推公式,然后实际操作中横坐标加上x,纵坐标加上y就好了。

顺时针(i, j) -> (j, -i)

逆时针(i, j) -> (-j, i)

#include<bits/stdc++.h>
#define REP(i, a, b) for(register int i = (a); i < (b); i++)
#define _for(i, a, b) for(register int i = (a); i <= (b); i++)
using namespace std; const int MAXN = + ;
int a[MAXN][MAXN], t[MAXN][MAXN];
int n, m; void read(int& x)
{
int f = ; x = ; char ch = getchar();
while(!isdigit(ch)) { if(ch == '-') f = -; ch = getchar(); }
while(isdigit(ch)) { x = x * + ch - ''; ch = getchar(); }
x *= f;
} void work(int x, int y, int r, int z)
{
_for(i, -r, r)
_for(j, -r, r)
{
if(z == ) t[x+i][y+j] = a[x+j][y-i];
else t[x+i][y+j] = a[x-j][y+i];
} _for(i, -r, r)
_for(j, -r, r)
a[i+x][j+y] = t[i+x][j+y];
} int main()
{
read(n); read(m);
_for(i, , n)
_for(j, , n)
a[i][j] = (i - ) * n + j; while(m--)
{
int x, y, r, z;
read(x); read(y); read(r); read(z);
work(x, y, r, z);
} _for(i, , n)
{
_for(j, , n)
printf("%d ", a[i][j]);
puts("");
} return ;
}

待补……

最新文章

  1. PHP:Xdebug配置
  2. styleId妙用
  3. jquery最常用的几个方法。
  4. hdu5432 二分
  5. 在opencv3中实现机器学习之:利用正态贝叶斯分类
  6. ASP.NET中在不同的子域中共享Session
  7. Xcode6.1模拟器ios8.1模拟器不能弹出虚拟键盘及虚拟键盘无法切换中文输入的解决办法
  8. 【原创】Linux编译内核
  9. [转帖]FPGA--Vivado
  10. [笔记] /etc/init.d/ 下脚本的通用结构
  11. Lucene 的索引文件锁原理
  12. Oracle树查询及相关函数
  13. 【转】android IDE——通过DDMS查看app运行时所占内存情况
  14. web.xml配置DispatcherServlet (***-servlert.xml)
  15. hive中的几个参数:元数据配置、仓库位置、打印表字段相关参数
  16. fragment 与activity通信 Bundle 序列化数据 Serializable
  17. 代码记录——phase16,block36(修正后)
  18. iOS设置圆角的三种方式
  19. ArrayList的去重问题
  20. spark ALS 推荐算法参数说明

热门文章

  1. Hibernate 事务和并发控制
  2. 提高生产力:SpringMVC中,使用扩展数据类型TypedMap接收Web请求参数
  3. 关于安卓sdk开发环境的的更新-Android SDK下载和更新失败
  4. 【Codeforces 469B】Chat Online
  5. 监控Weblogic计数器
  6. Shiro身份认证授权原理
  7. ExtJs之Ext.XTemplate:模板成员函数
  8. Oracle学习(11):PLSQL程序设计
  9. hdoj--1166--敌兵布阵(线段树)
  10. BZOJ 3052 树上带修莫队