FZU 2140 Forever 0.5
Problem 2140 Forever 0.5
Accept: 36 Submit: 113 Special Judge
Time Limit: 1000 mSec Memory Limit : 32768 KB
Problem Description
Given an integer N, your task is to judge whether there exist N points in the plane such that satisfy the following conditions:
1. The distance between any two points is no greater than 1.0.
2. The distance between any point and the origin (0,0) is no greater than 1.0.
3. There are exactly N pairs of the points that their distance is exactly 1.0.
4. The area of the convex hull constituted by these N points is no less than 0.5.
5. The area of the convex hull constituted by these N points is no greater than 0.75.
Input
The first line of the date is an integer T, which is the number of the text cases.
Then T cases follow, each contains an integer N described above.
1 <= T <= 100, 1 <= N <= 100
Output
For each case, output “Yes” if this kind of set of points exists, then output N lines described these N points with its coordinate. Make true that each coordinate of your output should be a real number with AT MOST 6 digits after decimal point.
Your answer will be accepted if your absolute error for each number is no more than 10-4.
Otherwise just output “No”.
See the sample input and output for more details.
Sample Input
Sample Output
Hint
This problem is special judge.
题意 :给你一个数n,让你找出n个点,满足一下关系:
- 任意两点的距离不大于1.0
- 所有点到原点的距离不大于1.0
- 恰好有N对点的距离为1.0
- 由这些点构成的n边形的面积不小于0.5
- 由这些点构成的n边形的面积不大于0.75
如果有就输出yes加上这n个点,如果没有就输出no
思路 : 这个题一开始看样例觉得好复杂,其实画个图推一下倒是可以看出来,要满足上边的条件至少要是4个点,3个点的话是一个等边三角形,面积不符合。因为条件中老是提到1,其实就是一个半径为1的圆以原点为圆心。然后以原点和x轴画一个边长为1的等边三角形,这样的话就有三个点了,其实前四个点都是可以确定的,然后剩下的点从圆上找就可以了,主要是别离那三个点的距离大于1即可,因为圆上的点到圆心的距离都为1,其实就是将圆离散化。
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std ;
double x[],y[] ;
const double temp = 0.005 ;
void chart()
{
x[] = ,y[] = ;
x[] = ,y[] = ;
x[] = 0.5,y[] = sqrt(1.0-0.25) ;
x[] = 0.5 ,y[] = y[]- ;
for(int i = ; i < ; i++)
{
y[i] = i*temp ;
x[i] = sqrt(-y[i]*y[i]) ;
}
}
int main()
{
int T,n ;
chart() ;
scanf("%d",&T) ;
while(T--)
{
scanf("%d",&n) ;
if(n < )
printf("No\n") ;
else
{
printf("Yes\n") ;
for(int i = ; i < n ; i++)
printf("%.6lf %.6lf\n",y[i],x[i]) ;
}
}
return ;
}
FZU 2140 Forever 0.5的更多相关文章
- FZU 2140 Forever 0.5(找规律,几何)
Problem 2140 Forever 0.5 Accept: 371 Submit: 1307 Special Judge Time Limit: 1000 mSec Memory Limit : ...
- FZU 2140 Forever 0.5 (几何构造)
Forever 0.5 Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit ...
- FZU 2140 Forever 0.5(将圆离散化)
主要就是将圆离散化,剩下的都好办 #include<iostream> #include<cstdio> #include<cstring> #include< ...
- ACM学习历程—FZU 2140 Forever 0.5(计算几何 && 构造)
Description Given an integer N, your task is to judge whether there exist N points in the plane su ...
- fzu Problem 2140 Forever 0.5(推理构造)
题目:http://acm.fzu.edu.cn/problem.php?pid=2140 题意: 题目大意:给出n,要求找出n个点,满足: 1)任意两点间的距离不超过1: 2)每个点与(0,0)点的 ...
- Hadoop-2.2.0 + Hbase-0.96.2 + Hive-0.13.1(转)
From:http://www.itnose.net/detail/6065872.html # 需要软件 Hadoop-2.2.0(目前Apache官网最新的Stable版本) Hbase-0.96 ...
- _00018 Hadoop-2.2.0 + Hbase-0.96.2 + Hive-0.13.1 分布式环境整合,Hadoop-2.X使用HA方式
博文作者:妳那伊抹微笑 itdog8 地址链接 : http://www.itdog8.com(个人链接) 博客地址:http://blog.csdn.net/u012185296 个性签名:世界上最 ...
- MTK Recovery 模式横屏修改(适用于6.0 + 8.1)
修改前 修改后 6.0 Recovery 模式横屏修改方法 修改相关文件 bootable\recovery\minui\Android.mk bootable\recovery\minui\mt_g ...
- 系统级性能分析工具perf的介绍与使用
测试环境:Ubuntu16.04(在VMWare虚拟机使用perf top存在无法显示问题) Kernel:3.13.0-32 系统级性能优化通常包括两个阶段:性能剖析(performance pro ...
随机推荐
- 亲测 asp.net 调用 webservice返回json
前端脚本 $("#sure").click(function () { var tbody = $("#putsigal tbody"); var trs = ...
- HTTP层 —— 控制器
1.简介 将所有的请求处理逻辑都放在单个 routes.php 中显然是不合理的,你也许还希望使用控制器类组织管理这些行为.控制器可以将相关的 HTTP 请求封装到一个类中进行处理.通常控制器存放在 ...
- java基础总结
/查看数组是否为空 String[] aorgPks = userRole.getAssignOrgPks(); if(ArrayUtils.isEmpty(aorgPks)){ //uapstudi ...
- 【MINA】用protobuf做编解码协议
SOCKET协议 支持java serial 与 AMF3的混合协议,目前没有基于xml 与 json的实现. 协议说明: * 9个字节协议头+协议体. * * 协议头1-4字节表示协议长度 =协议体 ...
- openvswitch安装和使用 --修订通用教程的一些错误
1.下载openvswitch源文件,注意版本要适合操作系统内核. 推荐openvswitch2.0及其以上版本. 2.开始安装openvswitch cd openvswitch sudo ./bo ...
- asp.net 控件 导出 excel
//导出EXCEL protected void btnDaoChu_Click(object sender, EventArgs e) { HttpContext.Current.Response. ...
- 性能更好的js动画实现方式——requestAnimationFrame
本文转载,原文地址:http://www.cnblogs.com/2050/p/3871517.html 用js来实现动画,我们一般是借助setTimeout或setInterval这两个函数,css ...
- 最短路 dijkstra and floyd
二:最短路算法分析报告 背景 最短路问题(short-path problem):若网络中的每条边都有一个数值(长度.成本.时间等),则找出两节点(通常是源节点和阱节点)之间总权和最小的路径就是最短路 ...
- 在Windows下用Mingw 4.5.2编译X264
1.下载mingw-get-inst-20110530.rar(http://www.baidu.com/link?url=-ixXW6QiuEl8CA1dKudoWCxzcTvxrpQ0nXRBHU ...
- 【转】提高PHP性能的53个技巧
PHP技巧汇总:提高PHP性能的53个技巧用单引号代替双引号来包含字符串,这样做会更快一些.因为PHP会在双引号包围的字符串中搜寻变量,单引号则不会,注意:只有echo能这么做,它是一种可以把多个字符 ...