题目链接: http://acm.timus.ru/problem.aspx?space=1&num=1963

题意,顺时针或逆时针给定4个坐标,问对称轴有几条,输出(对称轴数*2)

对于一条对角线,若他是对称轴,必须满足:另外2点关于这条对角线对称  =》 2条对角线互相垂直且 与这条对角线形成的夹角相等

而对于每条边的中点,只需要证明中点相连后与其所在的边垂直即可,垂直且相等就可以证明是对称的

#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <cctype>
#include <queue>
#include <stdlib.h>
#include <cstdlib>
#include <math.h>
#include <set>
#include <vector>
#define eps 1e-8
#define N 10
using namespace std; struct point {
double x,y;
}p[N]; bool eq(double a,double b){return (a-b>0?a-b:b-a)<eps;} bool chuizhi(point a,point b,point c,point d){
if(!eq(a.x,b.x) && !eq(c.x,d.x))
return eq(((a.y-b.y)*(c.y-d.y))/((a.x-b.x)*(c.x-d.x)),-1);
if(eq(a.x,b.x))return eq(c.y,d.y);
if(eq(c.x,d.x))return eq(a.y,b.y);
}
double dis(point a,point b){ return sqrt((double)((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)));}
double du(point a,point b,point c){
double d1=dis(a,b),d2=dis(b,c),d3=dis(c,a);
return (d1*d1+d3*d3-d2*d2)/d1*d3;
}
double k(point a,point b){//斜率
if(a.x==b.x)return 456453454154.154674;
return (a.y-b.y)/(a.x-b.x);
}
bool jiaodu(point a,point b,point c,point d)//a能否作为答案
{//a,b对边 c,d对边
point temp={(c.x+d.x)/2,(c.y+d.y)/2};
if(eq(k(a,b),k(a,temp)))return true;
return false;
}
void zhongdian(){
p[4].x=(p[0].x+p[1].x)/2,p[4].y=(p[0].y+p[1].y)/2;
p[5].x=(p[1].x+p[2].x)/2,p[5].y=(p[1].y+p[2].y)/2;
p[6].x=(p[2].x+p[3].x)/2,p[6].y=(p[2].y+p[3].y)/2;
p[7].x=(p[3].x+p[0].x)/2,p[7].y=(p[0].y+p[3].y)/2;
}
int main() {
while (scanf ("%lf%lf", &p[0].x, &p[0].y) != EOF) {
for (int i=1; i<4; ++i) scanf ("%lf%lf", &p[i].x, &p[i].y);
int ans=0;
zhongdian(); if(chuizhi(p[0],p[2],p[1],p[3])&& jiaodu(p[0],p[2],p[1],p[3]))ans++;
if(chuizhi(p[1],p[3],p[0],p[2])&& jiaodu(p[1],p[3],p[0],p[2]))ans++;
if(chuizhi(p[4],p[6],p[0],p[1]) && chuizhi(p[4],p[6],p[2],p[3]))ans++;
if(chuizhi(p[5],p[7],p[0],p[3]) && chuizhi(p[5],p[7],p[1],p[2]))ans++;
printf("%d\n",ans*2);
}
return 0;
} /*
0 0
0 9999
9999 9999
9999 0 0 0
1 2
2 2
2 1 ans:
8
2 */

URAL 1963 Kite 四边形求对称轴数的更多相关文章

  1. URAL 1963 Kite 计算几何

    Kite 题目连接: http://acm.hust.edu.cn/vjudge/contest/123332#problem/C Description Vova bought a kite con ...

  2. 帮初学者改代码——playerc之“练习:求完数问题”(下)

    前文链接:帮初学者改代码——playerc之“练习:求完数问题”(上) 再来看看be_ferfect()应该如何改. be_ferfect()函数的功能是判断number是否为完数,同时把因子对写入d ...

  3. 帮初学者改代码——playerc之“练习:求完数问题”(上)

    原文:“练习:求完数问题” 原代码: // #include <stdio.h> #include <stdlib.h> #include <math.h> #de ...

  4. openmp 并行求完数

    // GetWanShu.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include "omp.h" #inclu ...

  5. d008: 求两数的整数商 和 商

    内容: 求两数的整数商 和 商 ,商保留两位小数 输入说明: 一行 两个整数 输出说明: 一行,一个整数,一个实数(两位小数) 输入样例:   12 8 输出样例 : 1 1.50 #include ...

  6. d007: 求两数的整数商 和 余数

    内容: 求两数的整数商 和 余数 输入说明: 一行两个整数 输出说明: 一行两个整数 输入样例:   18 4 输出样例 : 4 2 #include <stdio.h> int main ...

  7. ZOJ3574(归并排序求逆数对)

    Under Attack II Time Limit: 5 Seconds      Memory Limit: 65536 KB Because of the sucessfully calcula ...

  8. 求数组的最小数、最大值,求一组数的平均数,sort函数详解,类数组转数组

    求数组的最小值和最大值 //求数组当中最大值和最小值 var arr=[3,2,6,1,45,23,456,23,2,6,3,45,37,89,30]; //第一种方法 根据排序方法来求最大值和最小值 ...

  9. Jsの数组练习-求一组数中的最大值和最小值,以及所在位置

    要求:求一组数中的最大值和最小值,以及所在位置 代码实现: <!DOCTYPE html> <html lang="en"> <head> &l ...

随机推荐

  1. iTextSharp

    iTextSharp 116毫秒处理6G的文件   前言: 有一家印刷企业专为米兰新娘,微微新娘,金夫人这样的影楼印刷婚纱相册.通过一个B2B销售终端软件,把影楼的相片上传到印刷公司的服务器,服务器对 ...

  2. 【C++】第二章:Hello World!

    1.开发工具:Microsoft Visual C++ v6.0 2.通过IDE建立Hello World程序: 我们可以看到三个文件夹结构,分别是: Source Files(源文件). Heade ...

  3. OPENSSL库的使用-DES篇

    一.单DES算法ECB模式加解密 1.使用函数DES_set_key_unchecked设置密钥 2.使用函数DES_ecb_encrypt来进行数据加解密 void DES_ecb_encrypt( ...

  4. CentOS 6.2 二进制安装apache2.4.3出现configure: error: APR-util not found. Please read the documentation的解决方

    CentOS 6.2 二进制安装apache2.4.3出现configure: error: APR-util not found. Please read the documentation的解决方 ...

  5. Websense一面、二面及Offer

    1.  写脚本打印当前目录(子目录)下文件内容中包含abc字符串文件 2.  用C写一个管道通信的程序:父进程向子进程写一个”hello word”字符串,子进程输出. 3.  解释I-node. 4 ...

  6. loadrunner参数化总结

    Select next row:Sequential,Rondom,Unique Update value on:Each iteration,Each occurrence,Once 下面分别对这两 ...

  7. WCF技术剖析之五:利用ASP.NET兼容模式创建支持会话(Session)的WCF服务

    原文:WCF技术剖析之五:利用ASP.NET兼容模式创建支持会话(Session)的WCF服务 在<基于IIS的WCF服务寄宿(Hosting)实现揭秘>中,我们谈到在采用基于IIS(或者 ...

  8. Storm流计算之项目篇(Storm+Kafka+HBase+Highcharts+JQuery,含3个完整实际项目)

    1.1.课程的背景 Storm是什么? 为什么学习Storm? Storm是Twitter开源的分布式实时大数据处理框架,被业界称为实时版Hadoop. 随着越来越多的场景对Hadoop的MapRed ...

  9. MySQL数据库触发器(trigger)

    MySQL触发器(trigger):监视某种情况并触发某种操作 一:四要素 触发时间:before/after 地点:table 监视操作:insert/update/delete 触发操作:inse ...

  10. G - Self Numbers(2.2.1)

    G - Self Numbers(2.2.1) Time Limit:1000MS     Memory Limit:10000KB     64bit IO Format:%I64d & % ...