408. Game with points

Time limit per test: 0.25 second(s)
Memory limit: 65536
kilobytes
input: standard
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).

    Output

    Output 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的更多相关文章

  1. SGU 403 Scientific Problem

    403. Scientific Problem Time limit per test: 0.25 second(s)Memory limit: 65536 kilobytes input: stan ...

  2. SGU - 403 - Scientific Problem (水)

    403. Scientific Problem Time limit per test: 0.25 second(s) Memory limit: 65536 kilobytes input: sta ...

  3. 今日SGU 5.13

    SGU 146 题意:就是给你一个长度为l的圈,然后你跑步,每一段给你时间t和速度v,问你最后离起点多远 收获:就是把浮点数转为整数,然后但是会出现精度误差,比如l最多四位小数,那你就加0.00001 ...

  4. SGU 532. Building Foundation 暴力

    532. Building Foundation 题目连接: http://acm.sgu.ru/problem.php?contest=0&problem=532 Description A ...

  5. apache httpd服务器403 forbidden的问题

    一.问题描述 在apache2的httpd配置中,很多情况都会出现403. 刚安装好httpd服务,当然是不会有403的问题了.主要是修改了一些配置后出现,问题描述如下: 修改了DocumentRoo ...

  6. 有理数的稠密性(The rational points are dense on the number axis.)

    每一个实数都能用有理数去逼近到任意精确的程度,这就是有理数的稠密性.The rational points are dense on the number axis.

  7. [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. ...

  8. 遇到 HTTP 错误 403.14 - Forbidden?

    打开 http://localhost:1609 报错: HTTP 错误 403.14 - Forbidden Web 服务器被配置为不列出此目录的内容 解决方案一:设置默认首页 在 Web.conf ...

  9. nginx 访问目录403

    centos7.2默认安装好nginx后,会在/usr/share/nginx/html下作为主目录 但是如果想访问下面的目录会发现没有权限,返回403错误 这时候要注意在/etc/nginx/ngi ...

随机推荐

  1. 一个不错的linux学习资料下载的网址

    本文比较完整的讲述GNU make工具,涵盖GNU make的用法.语法.同时重点讨论如何为一个工程编写Makefile.作为一个Linux程序员,make工具的使用以及编写Makefile是必需的. ...

  2. c# List 所有操作方法例子

    using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Ref ...

  3. 十七、springboot配置FastJson为Spring Boot默认JSON解析框架

    前提 springboot默认自带json解析框架,默认使用jackson,如果使用fastjson,可以按照下列方式配置使用 1.引入fastjson依赖库: maven: <dependen ...

  4. python基础--subprocess模块

    可以执行shell命令的相关模块和函数有: os.system os.spawn* os.popen*          --废弃 popen2.*           --废弃 commands.* ...

  5. thinkphp5与thinkphp3.X对比

    原文https://www.cnblogs.com/wupeiky/p/5850108.html 首先声明本章节并非是指导升级旧的项目到5.0,而是为了使用3.X版本的开发者更快的熟悉并上手这个全新的 ...

  6. Hex Dump In Many Programming Languages

    Hex Dump In Many Programming Languages See also: ArraySumInManyProgrammingLanguages, CounterInManyPr ...

  7. CentOS7的firewall和安装iptables

    前言:CentOS7 的防火墙默认使用是firewall,而我们通常使用iptables: 本文记录了firewall基础的命令和iptables的安装和使用. firewall部分: part1 : ...

  8. Asis CTF 2015-Car_Market

    恰好找到了这道题的bin文件,就来做一下. 这道题目是一个经典的选单程序但是具有三级选单,在bss段存在指针数组ptr,ptr中的值指向每个主结构,其中主结构如下所示. [] model [] pri ...

  9. MIT6.006Lec02:DocumentDistance

    MIT6.006是算法导论,Lec02讲的是Document Distance(文档距离),比如比较两个文档相似度或者搜索引擎中都会用到. 计算步骤为: 1.将每个文档分离为单词 2.统计词频 3.计 ...

  10. PHP XML操作的各种方法解析

    PHP提供了一整套的读取 XML文件的方法,很容易的就可以编写基于 XML的脚本程序.本章将要介绍 PHP与 XML的操作方法,并对几个常用的 XML类库做一些简要介绍. XML是一种流行的半结构化文 ...