题目链接:点击打开链接

题意:

给定T表示case数

以下4行是一个case

每行2个点,u v

每次u能够绕着v逆时针转90°

问最少操作多少次使得4个u构成一个正方形。

思路:

枚举判可行

#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstdio>
using namespace std;
int hah,ijj;
int haifei;
template <class T>
inline bool rd(T &ret) {char c; int sgn;if(c=getchar(),c==EOF) return 0;while(c!='-'&&(c<'0'||c>'9')) c=getchar();sgn=(c=='-')?

-1:1; ret=(c=='-')?

0:(c-'0'); while(c=getchar(),c>='0'&&c<='9') ret=ret*10+(c-'0'); ret*=sgn; return 1; } template <class T> inline void pt(T x) { if (x <0) { putchar('-'); x = -x; } if(x>9) pt(x/10); putchar(x%10+'0'); } /// const double eps = 1e-8; const double pi = acos(-1.0); struct node { double x, y; }; bool dcmp(double i, double j) { return fabs(i - j) <= eps; } bool eq(const node& i, const node& j) { return dcmp(i.x, j.x) && dcmp(i.y, j.y); } /* x0= (x - rx0)*cos(a) - (y - ry0)*sin(a) + rx0 ; y0= (x - rx0)*sin(a) + (y - ry0)*cos(a) + ry0 ; */ node turn(const node& i, const node& j, double a) { node re; re.x= (i.x - j.x)*cos(a) - (i.y - j.y)*sin(a) + j.x; re.y= (i.x - j.x)*sin(a) + (i.y - j.y)*cos(a) + j.y; return re; } bool cc(const node& i, const node& j) { if (!dcmp(i.x, j.x)) return i.x < j.x; else return i.y < j.y; } double sqr(double x) { return x * x; } double D(node i, node j) { return sqr(i.x-j.x) + sqr(i.y-j.y); } double dis[20]; int idx; bool ok(node i, node j, node k, node z) { node ar[4]; ar[0]=i; ar[1]=j; ar[2]=k; ar[3]=z; idx = 0; for (int i = 0; i < 4; ++i) for (int j = i + 1; j < 4; ++j) dis[idx++]=D(ar[i],ar[j]); sort(dis, dis +idx); if (dcmp(dis[0], dis[3]) && !dcmp(dis[0], 0) && dcmp(dis[4], dis[5]) && dcmp(dis[0] * 2, dis[4])) { return true; } else return false; } int main() { node a[10], b[10]; int T; rd(T); while (T -- > 0) { for (int i = 0; i < 4; ++i) scanf("%lf%lf%lf%lf", &a[i].x, &a[i].y, &b[i].x, &b[i].y); int ans = 100; for (int i = 0; i < 4; ++i) for (int j = 0; j < 4; ++j) for (int k = 0; k < 4; ++k) for (int l = 0; l < 4; ++l) if (ok(turn(a[0], b[0], i*pi/2),turn(a[1], b[1], j*pi/2), turn(a[2], b[2], k*pi/2),turn(a[3], b[3], l*pi/2))) { ans = min(i+j+k+l, ans); } if (ans == 100) ans = -1; pt(ans); putchar('\n'); } return 0; }

Codeforces 474C Captain Marmot 给定4个点和各自旋转中心 问旋转成正方形的次数相关推荐

  1. Codeforces Round #271 (Div. 2) C. Captain Marmot (暴力枚举+正方形判定)

    题目链接:Codeforces Round #271 (Div. 2) C. Captain Marmot 题意:给4行数据,每行2个点.(x,y).(a,b).意思是(x,y)绕(a,b)逆时针旋转 ...

  2. Codeforces 474 C. Captain Marmot

    4*4*4*4暴力+点的旋转+推断正方型 C. Captain Marmot time limit per test 1 second memory limit per test 256 megaby ...

  3. 给定一字符串,按顺时针顺序输出为一个正方形

    给定一字符串,按顺时针顺序输出为一个正方形,具体规则如下: 1.从上边开始,上边从左到右 2.然后到右边,右边从上到下 3.然后是下边,下边从右到左 4.最后是左边,左边从下到上. 示例1 输入 ab ...

  4. 2020-06-10:给定一个无序数组,里面数都是成双数的,只有一个数是成单数的,求这个数? 如果上面那题里面有两个单数,怎么求出来?

    1.异或 2.字典或集合 3.排序 golang语言采用异或方式,代码如下: package test22_singlenumber3import ("fmt""test ...

  5. 2020-06-09:给定一个无序数组,里面数都是成双数的,只有一个数是成单数的,求这个数?

    1.异或 2.字典或集合 3.排序 golang语言采用异或方式,代码如下: package test21_singlenumberimport ("fmt""testi ...

  6. ACC编程应用挑战赛决赛真题

    目录 哈喽 真题 题目一--圈地盘 题目二--门票 题目三--免单挑战 题目四--逃脱 题目五--一夫当关 题目六--游乐场 最后 哈喽 Hello!昨天是六一儿童节,可在雅安接连发生了6.1.4.3 ...

  7. 解题报告(十八)数论题目泛做(Codeforces 难度:2000 ~ 3000 + )

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 繁凡出品的全新系列:解题报告系列 -- 超高质量算法题单,配套我写的超高质量的题解和代码,题目难度不一 ...

  8. Codeforces Round #462 (Div. 2)题解

    Codeforces Round #462 (Div. 2) B题--我固执的认为1e18是18位数,导致被hack,花了20分钟才检查出这个错误,很僵硬 Codeforces 934C 题意 给定一 ...

  9. CodeForces - 434D Nanami's Power Plant

    Codeforces - 434D 题目大意: 给定一个长为n的序列,序列中的第i为上的值\(x_i\),序列第i位上的值\(x_i\in[l_i,r_i]\),价值为\(f_i(x_i)\),其中\ ...

最新文章

  1. 随机生成6位图片验证码
  2. 训练数据也外包?这家公司“承包”了不少注释训练数据,原来是这样做的……...
  3. docker 建mysql
  4. 需求用例分析之七:业务用例之小结
  5. tiny4412移植tslib库
  6. 决定好好研究一些开源的系统
  7. Python实现堆排序
  8. VS打包项目详细解析
  9. axios 全攻略之基本介绍与使用(GET 与 POST)
  10. 【唐宇迪 深度学习-3D点云实战系列】学习笔记
  11. 3D Motion Capture(3D运动捕捉)
  12. [转载]八种常见的防盗链方法总结及分析
  13. 计算机操作系统 第三章:处理机调度与死锁(2)
  14. word文档里四级目录无法显示
  15. AI 智能头像生成神器|PhotoShot
  16. Vue进阶(壹佰):当前页面刷新并重载页面数据
  17. 数据管理执行指南 | 你需要知道什么?
  18. 揭示win32 api拦截细节
  19. Microsoft IExpress:微软自带的安装程序包制作工具
  20. oracle组合数据类型,oracle复合数据类型-ZT

热门文章

  1. 据说 99% 的人不知道 vue-devtools 还能直接打开对应组件文件?本文原理揭秘
  2. 前端工程师的一大神器——puppeteer
  3. Silverlight之工具箱使用1
  4. JS---------正则表达式
  5. 【hive】——metastore的三种模式
  6. ubuntun中文读书笔记
  7. Libsvm分类步骤
  8. 在VHD文件上安装Windows 7或Windows 2008 R2
  9. Oracle 11G 安装详解
  10. Arts 第十九周(7/22 ~ 7/28)