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 ...
随机推荐
- c# 通过Windows服务启动外部程序
1. 新建一个Windows服务应用程序 创建项目——>Visual C# 左侧的"+"——>Windows ——>Windows 服务(右侧模板)——>输 ...
- gbdt和xgboost api
class xgboost.XGBRegressor(max_depth=3, learning_rate=0.1, n_estimators=100, silent=True, objective= ...
- [转]python与numpy基础
来源于:https://github.com/HanXiaoyang/python-and-numpy-tutorial/blob/master/python-numpy-tutorial.ipynb ...
- Python基础 - Ubuntu+Nginx+uwsgi+supervisor部署Flask应用
网上找了许多讲关于Flask应用部署的文章几乎都是一个helloworld的Demo,按照helloworld来部署都没问题,但实际项目部署时还是遇到了不少问题.在这里简单写下自己成功部署的过程,防止 ...
- bzoj 1218: [HNOI2003]激光炸弹
思路:二维前缀和, 枚举矩形左上端点. #include<bits/stdc++.h> #define LL long long #define fi first #define se s ...
- Request常用方法(转)
原文地址:http://www.lihuai.net/program/python/1617.html Python Requests库:HTTP for Humans 时间: 2014/12/30 ...
- UVA - 120Stacks of Flapjacks (摊煎饼。。)排序
/* 这题使我记起了以前很多忘掉的东西,例如sstream(分割流),deque(双端队列),还有众多函数(STL里的).值得收藏 值得注意的是这题的序号问题,(因为要求输出翻转的位置),序号从右往左 ...
- 在Ubuntu18.04中QT编程的环境构建(转)
在Ubuntu18.04中QT编程的环境构建 原点分析 百家号06-2110:14 如果说QT大家觉得陌生的话,那么 Windows 早年推出的C++图形用户界面的应用程序开发框架MFC,应该是耳熟能 ...
- spring boot上传文件错误The temporary upload location [/tmp/tomcat.5260880110861696164.8090/work/Tomcat/localhost/ROOT] is not valid
参考了:https://www.jianshu.com/p/cfbbc0bb0b84 再次感谢,但还是有些调整 一.在zuul服务中加入两个配置参数(location: /data/apps/temp ...
- UVa210 Concurrency Simulator (ACM/ICPC World Finals 1991) 双端队列
Programs executed concurrently on a uniprocessor system appear to be executed at the same time, but ...