当前位置:网站首页>有关直角坐标系旋转(n*90°)(1 ≤ n ≤ 4)的坐标求解
有关直角坐标系旋转(n*90°)(1 ≤ n ≤ 4)的坐标求解
2022-07-16 22:40:00 【Aidan 347】


设初始点为(x1,y1),易知y4 = x1,再通过与点(y1,x1)横坐标之间的关系(x4 + y1 = n + 1);
可知x4 = n + 1 - y1;
再由中心对称 x2 = n + 1 - x4; y2 = n + 1 - y4;
而(x3,y3)可由(x1,y1)中心对称可得: x3 = n + 1 - x1, y3 = n + 1 - y1;
int y4 = x1;
int x4 = y1;
x4 = n + 1 - x4;
int x2 = n + 1 - x4;
int y2 = n + 1 - y4;
int x3 = n + 1 - x1;
int y3 = n + 1 - y1;
以上是求解坐标的过程
本题要求4个旋转角度得到的都是同一个矩阵,那么就要求每一个1/4矩阵中的点都与他的相关旋转点相同,可以枚举1/4矩阵中的每一个点,通过check(i,j)返回需要改变的点的最小数量
#include <iostream>
#include <cstring>
#include <algorithm>
#include <queue>
#include <vector>
#include <cmath>
#include <map>
#include <set>
using namespace std;
#define mst(x, y) memset(x, y, sizeof x);
#define X first
#define Y second
#define int long long
#define FAST ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
const int N = 1010, INF = 0x3f3f3f3f, EPS = 1e-8;
typedef pair<int, int> PII;
int t, n;
char g[N][N];
int check(int x1, int y1)
{
int y4 = x1;
int x4 = y1;
x4 = n + 1 - x4;
int x2 = n + 1 - x4;
int y2 = n + 1 - y4;
int x3 = n + 1 - x1;
int y3 = n + 1 - y1;
int res = 0;
if (g[x1][y1] == '1')
res++;
if (g[x2][y2] == '1')
res++;
if (g[x3][y3] == '1')
res++;
if (g[x4][y4] == '1')
res++;
return min(res, 4 - res);
}
signed main()
{
FAST;
cin >> t;
while (t--)
{
cin >> n;
for (int i = 1; i <= n; i++)
cin >> g[i] + 1;
int res = 0;
for (int i = 1; i <= (n + 1) / 2 - (n % 2); i++)
{
for (int j = 1; j <= (n + 1) / 2; j++)
{
res += check(i, j);
}
}
cout << res << endl;
}
return 0;
}
边栏推荐
- 解决华为笔记本安装驱动后浏览器频闪
- Kept - solve the problem that the primary and standby nodes seize the VIP at the same time
- Implementation of word2vec skip gram model
- 【无标题】
- WordPress Theme sharing: Avada theme v7.8.0 download the latest version in 2022 for free
- One of the series of articles on data access platform (DIP) | function and architecture analysis
- Go+mysql+redis+vue3 simple chat room, bullet 5: synchronize messages to MySQL using message queues and scheduled tasks
- Redis distributed cache - redis master-slave
- 曲面的局部理论Differential Geometry之第三章
- 有的小伙伴问我英语不好可以学编程吗?
猜你喜欢
![ETS development mode tripartite component recommendation [Series 1]](/img/53/e0265832502c25e559bbae61c87db7.jpg)
ETS development mode tripartite component recommendation [Series 1]

25篇性能测试文章专题

Keepalived——解决 主备节点同时抢占VIP 的问题

Wechat applet development learning 3 (wxss template and global configuration)

笔记

WordPress主题分享:The7主题v10.11免费下载 2022年最新版

2022-07-15 advanced network engineering (XIX) BGP state machine, interaction principles between peers, factors affecting the establishment of peer relations, peer table, routing table, detailed routin

About the use of go modules environment construction and package management tools

Box model, table case

有的小伙伴问我英语不好可以学编程吗?
随机推荐
Redis distributed cache - Data Persistence
【论文阅读】YOLOv7: Trainable bag-of-freebies sets new state-of-the-art for real-time object detectors
大雪菜味题解--查找文献
面试官:工作两年了,这么简单的算法题你都不会?
如何设计接口测试用例?(文末送接口测试用例模板)
With responsible AI | three certificates, aopeng China has also obtained ISO9001 and 27701 certification
WordPress主题分享:Avada主题v7.8.0免费下载 2022年最新版
What are the advantages of using gtid to configure replication relative to coordinate position
Vs publish websites using webdeploy
2022-07-16 第五小组 修身课 学习笔记(every day)
php通过form表单上传Excel文件并把Excel数据导入到数据库中
Collection of various materials about websocket
20220707 thread learning inheritance
Keepalived——解决 主备节点同时抢占VIP 的问题
2022 - 07 - 16 notes d'étude pour le cours d'auto - culture du groupe 5 (tous les jours)
Explanation of the taste of snow vegetables -- searching for Literature
有效降低项目成本,从项目采购管理抓起
Recommend a blog about instant messaging
曲面的局部理论Differential Geometry之第三章
How does electron package its Kirin system to support godson, fangteng and megacore platforms