zoukankan      html  css  js  c++  java
  • [dp]Codeforces30C Shooting Gallery

    题目链接

    题意: 给n个点 每个点的坐标 x y 出现的时间t 射中的概率

    从i点到j点的时间为它们的距离.

    求射中个数的最大期望

    很水的dp  坑点就是要用LL

     1 #include <cstdio>
     2 #include <cstdlib>
     3 #include <cstring>
     4 #include <climits>
     5 #include <cctype>
     6 #include <cmath>
     7 #include <string>
     8 #include <sstream>
     9 #include <iostream>
    10 #include <algorithm>
    11 #include <iomanip>
    12 using namespace std;
    13 #include <queue>
    14 #include <stack>
    15 #include <vector>
    16 #include <deque>
    17 #include <set>
    18 #include <map>
    19 typedef long long LL;
    20 typedef long double LD;
    21 #define pi acos(-1.0)
    22 #define lson l, m, rt<<1
    23 #define rson m+1, r, rt<<1|1
    24 typedef pair<int, int> PI;
    25 typedef pair<int, PI> PP;
    26 #ifdef _WIN32
    27 #define LLD "%I64d"
    28 #else
    29 #define LLD "%lld"
    30 #endif
    31 //#pragma comment(linker, "/STACK:1024000000,1024000000")
    32 //LL quick(LL a, LL b){LL ans=1;while(b){if(b & 1)ans*=a;a=a*a;b>>=1;}return ans;}
    33 //inline int read(){char ch=' ';int ans=0;while(ch<'0' || ch>'9')ch=getchar();while(ch<='9' && ch>='0'){ans=ans*10+ch-'0';ch=getchar();}return ans;}
    34 //inline void print(LL x){printf(LLD, x);puts("");}
    35 //inline void read(double &x){char c = getchar();while(c < '0') c = getchar();x = c - '0'; c = getchar();while(c >= '0'){x = x * 10 + (c - '0'); c = getchar();}}
    36 
    37 const double eps=1e-6;
    38 struct node
    39 {
    40     LL x, y, t;
    41     double p;
    42 }a[1005];
    43 double dp[100005];
    44 bool cmp(node a, node b)
    45 {
    46     return a.t<b.t;
    47 }
    48 int main()
    49 {
    50 #ifndef ONLINE_JUDGE
    51     freopen("in.txt", "r", stdin);
    52     freopen("out.txt", "w", stdout);
    53 #endif
    54     int n;
    55     while(~scanf("%d", &n))
    56     {
    57         for(int i=0;i<n;i++)
    58         {
    59             scanf(LLD, &a[i].x);
    60             scanf(LLD, &a[i].y);
    61             scanf(LLD, &a[i].t);
    62             scanf("%lf", &a[i].p);
    63         }
    64         sort(a, a+n, cmp);
    65         memset(dp, 0, sizeof(dp));
    66         for(int i=0;i<n;i++)
    67         {
    68             dp[i]=a[i].p;
    69             for(int j=0;j<i;j++)
    70                 if((a[j].x-a[i].x)*(a[j].x-a[i].x)+(a[j].y-a[i].y)*(a[j].y-a[i].y)<=(a[j].t-a[i].t)*(a[j].t-a[i].t)+eps)
    71                     dp[i]=max(dp[i], a[i].p+dp[j]);
    72         }
    73         double ans=0;
    74         for(int i=0;i<n;i++)
    75             ans=max(ans, dp[i]);
    76         printf("%.10lf
    ", ans);
    77     }
    78     return 0;
    79 }
    Codeforces 30C
  • 相关阅读:
    Microsoft Visual C++ 2015安装失败,提示设置失败,一个或多个问题导致了安装失败
    C# 下载url文件 WebClient、HttpWebRequest
    sqlite中插入单引号
    Advanced Installer 14.9 – WPF或winform应用程序打包成exe文件
    凤凰队历险记
    GUI如何设置默认字体 转载
    ubuntu切换清华源 安装gcc
    AttributeError: module ‘arviz’ has no attribute ‘geweke’
    解决ssh 连接报错 network error software caused connection abort 自动中断 转载
    VMWare安装64位CentOS7.6(截图多)
  • 原文地址:https://www.cnblogs.com/Empress/p/4063847.html
Copyright © 2011-2022 走看看