zoukankan      html  css  js  c++  java
  • cf 1C

    C. Ancient Berland Circus
    time limit per test
    2 seconds
    memory limit per test
    64 megabytes
    input
    standard input
    output
    standard output

    Nowadays all circuses in Berland have a round arena with diameter 13 meters, but in the past things were different.

    In Ancient Berland arenas in circuses were shaped as a regular (equiangular) polygon, the size and the number of angles could vary from one circus to another. In each corner of the arena there was a special pillar, and the rope strung between the pillars marked the arena edges.

    Recently the scientists from Berland have discovered the remains of the ancient circus arena. They found only three pillars, the others were destroyed by the time.

    You are given the coordinates of these three pillars. Find out what is the smallest area that the arena could have.

    Input

    The input file consists of three lines, each of them contains a pair of numbers –– coordinates of the pillar. Any coordinate doesn't exceed 1000 by absolute value, and is given with at most six digits after decimal point.

    Output

    Output the smallest possible area of the ancient arena. This number should be accurate to at least 6 digits after the decimal point. It's guaranteed that the number of angles in the optimal polygon is not larger than 100.

    Sample test(s)
    input
    0.000000 0.000000
    1.000000 1.000000
    0.000000 1.000000
    output
    1.00000000

    题目大意是给出正多边形上的三个点坐标, 求这个正多边形的面积.

    由于是确定是正多边形,所以一定存在外接圆.所以可以分为如下几步:

    海伦公式: p=(a+b+c)/2      S=√p(p-a)(p-b)(p-c)

    1.求外接圆半径r=abc/4S

    2.由余弦定理求出三个圆心角ang[3]

    (要注意的是,有可能有三个点在同一段半圆弧上,这是第三个圆心角应该用2π-ang[0]-ang[1], 所以干脆全部都是ang[2]=2π-ang[0]-ang[1])

    3.求这三个角的最大公约数为A, 那么这就是一个正2π/A边形.

    4.一个小三角形的面积S=1/2·r * r * sinA

    5.nS即为所求.

  • 相关阅读:
    使用MFC界面库LibUIDK制作超酷界面
    使用WSH和WMI实现定时记录系统CPU和内存使用率
    关于CreateFileMapping的问题
    360对NSIS误报Malware.QVM06.GEN的解决办法
    win2003实现单用户远程登录
    All bytes must be within the maximum size specified by CreateFileMapping
    解决在VS2005中“当前不会命中断点。源代码与原始版本不同”的问题
    static library中能不能带资源
    HUDSON_HOME
    USB GUID查找
  • 原文地址:https://www.cnblogs.com/a972290869/p/4227615.html
Copyright © 2011-2022 走看看