SGU 403 Game with points
408. Game with points
Memory limit: 65536
kilobytes
output: standard
Recently Petya has discovered new game with points. Rules of the game are quite simple. First, there is only
one point A0 with coordinates (0, 0). Then Petya have to draw N another points. Points must be drawn
consequently and each new point must be connected with exactly one of the previous points by a segment.
Let's decribe the game process more formally. At the i-th step Petya chooses the position of the point Ai (not
necessarily with integer coordinates). Than he chooses one of the previously drawn points in order to connect it with the
point Ai. Lets call this point B. The following conditions must be held:
- Point Ai must not coincide with any of the previous points.
- Point Ai must not lie on the previously drawn segments.
- Segment AiB must not have common points with previously drawn segments, except possibly the point B.
- Segment AiB must not cover any of the previous points, except the point B.
- Length of the segment AiB must not exceed 1. After drawing each point Petya computes two values.
- The largest number of segments which share a common point.
- The largest euclid distance between some pair of points. After each step Petya gains the score which is equal to the product of these values. Find out which is the maximal score Petya can gain after the whole game.
Input
Input contains single integer number N (0 ≤ N ≤ 1000).
OutputOutput the maximal score that Petya can gain. Your answer must be accurate up to 10-3.
Example(s)sample input
sample output
2
5.000
sample input
sample output
4
20.000
#include<iostream>
#include<string.h>
#include<stdio.h>
#include<ctype.h>
#include<algorithm>
#include<stack>
#include<queue>
#include<set>
#include<math.h>
#include<vector>
#include<map>
#include<deque>
#include<list>
using namespace std;
int a[];
int b[]; int main()
{
//freopen("in.txt", "r", stdin);
int n;
scanf("%d", &n);
a[] = ;
b[] = ; if (n == ) printf("0.000\n");
else if (n == )printf("1.000\n");
else if (n == )printf("5.000\n");
else
{
double ans = ;
int m = , d = ;
for (int i = ; i <n; i++)
{
if ((m + )*d >= m*(d + ))
m++;
else
d++;
ans += m*d;
}
printf("%.3lf\n", ans);
} return ;
}
SGU 403 Game with points的更多相关文章
- SGU 403 Scientific Problem
403. Scientific Problem Time limit per test: 0.25 second(s)Memory limit: 65536 kilobytes input: stan ...
- SGU - 403 - Scientific Problem (水)
403. Scientific Problem Time limit per test: 0.25 second(s) Memory limit: 65536 kilobytes input: sta ...
- 今日SGU 5.13
SGU 146 题意:就是给你一个长度为l的圈,然后你跑步,每一段给你时间t和速度v,问你最后离起点多远 收获:就是把浮点数转为整数,然后但是会出现精度误差,比如l最多四位小数,那你就加0.00001 ...
- SGU 532. Building Foundation 暴力
532. Building Foundation 题目连接: http://acm.sgu.ru/problem.php?contest=0&problem=532 Description A ...
- apache httpd服务器403 forbidden的问题
一.问题描述 在apache2的httpd配置中,很多情况都会出现403. 刚安装好httpd服务,当然是不会有403的问题了.主要是修改了一些配置后出现,问题描述如下: 修改了DocumentRoo ...
- 有理数的稠密性(The rational points are dense on the number axis.)
每一个实数都能用有理数去逼近到任意精确的程度,这就是有理数的稠密性.The rational points are dense on the number axis.
- [LeetCode] Max Points on a Line 共线点个数
Given n points on a 2D plane, find the maximum number of points that lie on the same straight line. ...
- 遇到 HTTP 错误 403.14 - Forbidden?
打开 http://localhost:1609 报错: HTTP 错误 403.14 - Forbidden Web 服务器被配置为不列出此目录的内容 解决方案一:设置默认首页 在 Web.conf ...
- nginx 访问目录403
centos7.2默认安装好nginx后,会在/usr/share/nginx/html下作为主目录 但是如果想访问下面的目录会发现没有权限,返回403错误 这时候要注意在/etc/nginx/ngi ...
随机推荐
- aarch64_o2
opensips-event_rabbitmq-2.2.3-1.fc26.aarch64.rpm 2017-03-10 01:22 42K fedora Mirroring Project opens ...
- React-Native 之 环境配置和简单使用
# 前言 学习本系列内容需要具备一定 HTML 开发基础,没有基础的朋友可以先转至 HTML快速入门(一) 学习 本人接触 React Native 时间并不是特别长,所以对其中的内容和性质了解可能会 ...
- linux文件管理 -> 系统文件属性
-rw-------. 1 root root 4434 May 30 13:58 ks.cfg -rw-------. ①:文件类型与权限 ②:硬链接次数 root ③:所属用户 root ④:所属 ...
- win、mac系统配置本地电脑ip为域名教程
win系统: 如何修改hosts文件 主机文件原内容如下: #Copyright(c)1993-2009 Microsoft Corp. # #这是Windows的Microsoft TCP / IP ...
- js函数前加分号和感叹号的作用
js函数前加分号和感叹号是什么意思?有什么用? 一般看JQuery插件里的写法是这样的 (function($) { //... })(jQuery); 今天看到bootstrap的javascrip ...
- hihoCoder #1184 : 连通性二·边的双连通分量(边的双连通分量模板)
#1184 : 连通性二·边的双连通分量 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 在基本的网络搭建完成后,学校为了方便管理还需要对所有的服务器进行编组,网络所的老 ...
- 整理一下关于Crypto加密的坑
之前写接口一般不用加密(做了权限处理),最近公司要求接口加密,我开始了入坑之路 因为公司其他人用的AES和DES加密,我就在网上查了下关于这方面的使用方法. 首先安装Crypto pip instal ...
- 2016-2017-2 20155309南皓芯《java程序设计》第七周学习总结
教材学习内容总结 Lambda 一种匿名方法 表达式构成 括号以及括号里用逗号分隔的参数列表 仅有一个参数的可以省略括号 ->符号 花括号以及花括号里的语句 仅有一条语句时可以省略花括号,并且这 ...
- matlab设定mex接驳的C/C++编译器
使用C/C++编写核心算法,使用matlab调用算法.做上层封装,通常是提升效率并提供易用性的一个不错的选择. mex需要设定接驳的C/C++编译器,官方文档在这里:https://ww2.mathw ...
- Filebeat配置paths里,不支持递归所有子目录
这个知识点要牢记哟,不然,牛B吹大了,收不回哈. 官方文档为证: Currently it is not possible to recursively fetch all files in all ...