zoukankan      html  css  js  c++  java
  • fzu Problem 2140 Forever 0.5(推理构造)

    题目:http://acm.fzu.edu.cn/problem.php?pid=2140

    题意:

    题目大意:给出n,要求找出n个点,满足: 
    1)任意两点间的距离不超过1; 
    2)每个点与(0,0)点的距离不超过1; 
    3)有n对点之间的距离刚好为1; 
    4)n个点组成的多边形面积大于0.5; 
    5)n个点组成的多边形面积小于0.75;

    思路:只要有4个点以上就是,构造时先找出四个点,再在半径为1的圆上找点就行。

    很巧妙的一道题目呀、、、、

     1 #include <iostream>
     2 #include <cstdio>
     3 #include <cstdlib>
     4 #include <cstring>
     5 #include <cmath>
     6 #include <algorithm>
     7 using namespace std;
     8 
     9 double x[110], y[110];
    10 void slo()
    11 {
    12     x[0] = 0; y[0] = 0;
    13     x[1] = 1; y[1] = 0;
    14     x[2] = 0.5; y[2] = sqrt(1-0.5*0.5);
    15     x[3] = 0.5; y[3] = y[2]-1;
    16     for(int i = 4; i < 102; i++)
    17     {
    18         x[i] = 1-0.001*i;
    19         y[i] = sqrt(1-x[i]*x[i]);
    20     }
    21 }
    22 int main()
    23 {
    24     int t, n;
    25     cin>>t;
    26     slo();
    27     while(t--)
    28     {
    29         cin>>n;
    30         if(n<=3)
    31             cout<<"No"<<endl;
    32         else
    33         {
    34             cout<<"Yes"<<endl;
    35             for(int i = 0; i < n; i++)
    36                 printf("%.6lf %.6lf
    ", x[i], y[i]);
    37         }
    38     }
    39     return 0;
    40 }
  • 相关阅读:
    生产者-消费者模式
    Java中数字操作
    Java中的装箱拆箱
    Java中的匿名类
    JAVA中抽象类的一些总结
    JAVA继承时this和super关键字
    elasticsearch查询
    elasticsearch的映射
    kibana——es的批量操作
    kibana简单使用——elaticsearch的文档,索引的CRUD操作
  • 原文地址:https://www.cnblogs.com/bfshm/p/3619903.html
Copyright © 2011-2022 走看看