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 kernel的中断子系统之(三):IRQ number和中断描述符【转】

    转自:http://www.wowotech.net/linux_kenrel/interrupt_descriptor.html 一.前言 本文主要围绕IRQ number和中断描述符(interr ...

  2. 【Android开发】之MediaPlayer的错误分析

    最近在做媒体播放器,使用了Android自带的MediaPlayer,经常性会碰到MediaPlayer报错的情况,找过网上的,感觉总结的不是很好或者比较散.下面,我来总结一下使用MediaPlaye ...

  3. 前端程序员必知的30个Chrome扩展-[转载]

    谷歌Chrome浏览器是网络上可用的最好浏览器之一,并且自2011年11月超越了Firefox浏览器之后,已经成为了互联网上占主导地位的浏览器.今天,HTML5中国与大家分享一些实用的谷歌Chrome ...

  4. elasticsearch5.5

    1.不能以root用户运行 groupadd es          #增加es组 useradd es -g es -p pwd          #增加es用户并附加到es组 chown -R e ...

  5. IntelliJ IDEA + Tomcat ;On Upate Action 与 On Frame Deactivation

    On Upate Action 与 On Frame Deactivation  这两个选项的设置,依赖于 项目的部署方式 是war包 还是 exploded ,看下面的gif: 这里实在是太灵活了, ...

  6. 使用T-SQL导入多个文件数据到SQL Server中

    在我们的工作中,经常需要连续输入多个文件的数据到SQL Server的表中,有时需要从相同或者不同的目录中,同时将文件中的数据倒入.在这篇文章中,我们将讨论如何同时把一个目录中的文件的数据倒入到SQL ...

  7. 20165203《Java程序设计》第二周Java学习总结

    教材学习内容总结 第二章 (一)标识符 注意: 标识符由字母.下画线.美元符号和数字组成,长度不受限制. 标识符第一个字符不能是数学字符. 标识符不能是关键字. 标识符不能是true.false和nu ...

  8. 20155225 实验四《Android程序设计》实验报告

    20155225 实验四<Android程序设计>实验报告 一.安装Android Stuidio 问题一:安装完成后,打开提示我找不到SDK,我已经设置了环境变量,关掉提示,没有影响. ...

  9. ASP.NET:MVC中文件上传与地址变化处理

    目录 文件的上传和路径处理必须解决下面列出的实际问题: 1.重复文件处理 2.单独文件上传 3.编辑器中文件上传 4.处理文章中的图片路径 5.处理上传地址的变化 一.上传文件和重复文件处理 文件处理 ...

  10. 在android studio中集成javah, ndk-build进行JNI开发

    最近在搞一个android上控制LED灯闪烁的功能,用到了串口编程,搜索了一下,发现Google发布了一个demo,android-serialport-api.有现成的代码和APK,要想自己改JNI ...