SGU 403 Game with points

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
     1 #include<iostream>  
     2 #include<string.h>  
     3 #include<stdio.h>  
     4 #include<ctype.h>  
     5 #include<algorithm>  
     6 #include<stack>  
     7 #include<queue>  
     8 #include<set>  
     9 #include<math.h>  
    10 #include<vector>  
    11 #include<map>  
    12 #include<deque>  
    13 #include<list>  
    14 using namespace std;
    15 int a[1111];
    16 int b[1111];
    17 
    18 int main()
    19 {
    20     //freopen("in.txt", "r", stdin);
    21     int n;
    22     scanf("%d", &n);
    23     a[1] = 1;
    24     b[1] = 1;
    25     
    26     if (n == 0) printf("0.000\n");
    27     else if (n == 1)printf("1.000\n");
    28     else if (n == 2)printf("5.000\n");
    29     else
    30     {
    31         double ans = 5;
    32         int m = 2, d = 2;
    33         for (int i = 2; i <n; i++)
    34         {
    35             if ((m + 1)*d >= m*(d + 1))
    36                 m++;
    37             else
    38                 d++;
    39             ans += m*d;
    40         }
    41         printf("%.3lf\n", ans);
    42     }
    43 
    44     return 0;
    45 }
    View Code

     

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值