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