题目I - Osu! - HDU 5078

题目分析:最水的一道题吧,求两点间的距离和时间差值的最大比值

#include<stdio.h>
#include<math.h>
#include<algorithm>
using namespace std; const int MAXN = ;
const double EPS = 1e-; struct Point
{
double x, y, time;
};
double Dist(Point a, Point b)
{
return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
int main()
{
int T; scanf("%d", &T); while(T--)
{
int i, N;
double ans = ;
Point p[MAXN]; scanf("%d", &N); for(i=; i<N; i++)
{
scanf("%lf%lf%lf", &p[i].time, &p[i].x, &p[i].y);
if(i == )
ans = Dist(p[i], p[i-]) / (p[i].time-p[i-].time);
else if(i > )
ans = max(ans, Dist(p[i], p[i-]) / (p[i].time-p[i-].time));
} printf("%.10f\n", ans);
} return ;
}

E - Hatsune Miku - HDU 5074

题目分析:把前后等于-1的情况分别讨论一下,就是一个简单的dp了.....

#include<stdio.h>
#include<math.h>
#include<string.h>
#include<algorithm>
using namespace std; const int MAXN = ;
const int oo = 1e9+; int main()
{
int T; scanf("%d", &T); while(T--)
{
int i, j, k, N, M;
int dp[MAXN][MAXN], a[MAXN], val[MAXN][MAXN]; memset(dp, , sizeof(dp)); scanf("%d%d", &N, &M); for(i=; i<=M; i++)
for(j=; j<=M; j++)
scanf("%d", &val[i][j]); for(i=; i<=N; i++)
scanf("%d", &a[i]); for(i=N-; i>; i--)
{
if(a[i] == - && a[i+] == -)
{
for(j=; j<=M; j++)
for(k=; k<=M; k++)
dp[i][j] = max(dp[i][j], val[j][k]+dp[i+][k]);
}
else if(a[i] == -)
{
for(j=; j<=M; j++)
dp[i][j] = max(dp[i][j], val[j][a[i+]]+dp[i+][a[i+]]);
}
else if(a[i+] == -)
{
for(j=; j<=M; j++)
dp[i][a[i]] = max(dp[i][a[i]], val[a[i]][j]+dp[i+][j]);
}
else
dp[i][a[i]] = val[a[i]][a[i+]] + dp[i+][a[i+]];
} int ans = ; for(i=; i<=M; i++)
ans = max(ans, dp[][i]); printf("%d\n", ans);
} return ;
}

D - Galaxy - HDU 5073

题目分析:首先注意输入的是无序....(为此WA一次),题意就是让求去掉K个点后,剩余的点到中心的平方和,中心点计算是 所有数的位置和 / 剩余点数,转变成了求一些数的方差之和,然后化简公式可以发现可以直接计算出来结果,只需要遍历一遍即可(剩余点数一定是连续的,很容易求证)。设剩余点数M,剩余点数的平方和是 sum,剩余点数的位置和是cnt,那么 ans = sum - cnt * cnt / sum, 求出来最小的ans。

#include<stdio.h>
#include<math.h>
#include<string.h>
#include<algorithm>
using namespace std; const int MAXN = 1e5+;
const int oo = 1e9+; double loc[MAXN]; int main()
{
int T; scanf("%d", &T); while(T--)
{
int i, N, M, K; scanf("%d%d", &N, &K); for(i=; i<N; i++)
scanf("%lf", &loc[i]);
sort(loc, loc+N); if(K + >= N)
{
printf("0\n");
continue;
} M = N - K;
double cnt=, ans, sum=; for(i=; i<M; i++)
{
cnt += loc[i];
sum += loc[i]*loc[i];
} ans = sum - cnt*cnt/M; for(i=M; i<N; i++)
{
sum = sum + loc[i]*loc[i] - loc[i-M]*loc[i-M];
cnt = cnt + loc[i] - loc[i-M]; ans = min(ans, sum-cnt*cnt/M);
} printf("%.10f\n", ans);
} return ;
}

2014 ACM-ICPC Asia Anshan Regional Contest(Online Version)的更多相关文章

  1. HDU 5000 2014 ACM/ICPC Asia Regional Anshan Online DP

    Clone Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/65536K (Java/Other) Total Submiss ...

  2. hdu 5016 点分治(2014 ACM/ICPC Asia Regional Xi'an Online)

    Mart Master II Time Limit: 12000/6000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)T ...

  3. ACM ICPC Central Europe Regional Contest 2013 Jagiellonian University Kraków

    ACM ICPC Central Europe Regional Contest 2013 Jagiellonian University Kraków Problem A: Rubik’s Rect ...

  4. 2019-2020 ICPC, Asia Jakarta Regional Contest (Online Mirror, ICPC Rules, Teams Preferred)

    2019-2020 ICPC, Asia Jakarta Regional Contest (Online Mirror, ICPC Rules, Teams Preferred) easy: ACE ...

  5. 2014 ACM/ICPC Asia Regional Anshan Online

    默默的签到 Osu! http://acm.hdu.edu.cn/showproblem.php?pid=5003 #include<cstdio> #include<algorit ...

  6. HDU 5002 Tree(动态树LCT)(2014 ACM/ICPC Asia Regional Anshan Online)

    Problem Description You are given a tree with N nodes which are numbered by integers 1..N. Each node ...

  7. HDU 5000 Clone(离散数学+DP)(2014 ACM/ICPC Asia Regional Anshan Online)

    Problem Description After eating food from Chernobyl, DRD got a super power: he could clone himself ...

  8. 2014 ACM/ICPC Asia Regional Shanghai Online

    Tree http://acm.hdu.edu.cn/showproblem.php?pid=5044 树链剖分,区间更新的时候要用on的左++右--的标记方法,要手动扩栈,用c++交,综合以上的条件 ...

  9. 2014 Asia AnShan Regional Contest --- HDU 5073 Galaxy

    Galaxy Problem's Link:   http://acm.hdu.edu.cn/showproblem.php?pid=5073 Mean: 在一条数轴上,有n颗卫星,现在你可以改变k颗 ...

随机推荐

  1. Javascript实现图片库效果

    思路: 无序列表加载图片文件.用img标签加载一张图片作为占位符.当点击照片链接时,改变<a>元素的href属性.并且阻止浏览器的默认行为. 动态改变描述文字,在图片下方增加P标签.通过获 ...

  2. Lucene初步搜索

    Lucene在创立索引后,要进行搜索查询 搜索大概需要5部, 1,读取索引. 2,查询索引. 3,匹配数据. 4,封装匹配结果. 5,获取需要的值. 语言表达能力不好,大概就是分着几部吧. /** * ...

  3. ubuntu1404下Apache2.4错误日志error.log路径位置

    首先打开/etc/apache2路径下的apache2.conf文件,找到ErrorLog如下 ErrorLog ${APACHE_LOG_DIR}/error.log 这里{APACHE_LOG_D ...

  4. header("Location:login.php")

    header("Location:login.php")应该注意的几个问题  header("Location:")作为php的转向语句.其实在使用中,他有几点 ...

  5. oracle建立表空间

    //创建临时表空间 create temporary tablespace test_temp tempfile 'E:\oracle\product\10.2.0\oradata\testserve ...

  6. 按钮效果 css

    <!doctype html><html lang="en"><head> <meta charset="UTF-8" ...

  7. 判断IE浏览器用IE条件表达式

    <!--[if IE]> <script type="text/javascript"> alert("ie") </script ...

  8. Js 获取 本周、本月起始时间

    涉及到显示本月或本周相关信息,又不想让php去判断,只好直接用js去计算,麻烦了好一阵,还是老老实实的看了下js的日期函数.现总结一下: //计算本周起始日期,并以 Y-m-d 形式返回.    fu ...

  9. 帝国cms7.0跳过[会员注册类型]这步的方法

    改 e/config/config.php 文件,把$ecms_config['member']['changeregisterurl']="ChangeRegister.php" ...

  10. property测试代码:

    // // main.m // TestVar2 // // Created by lishujun on 14-9-4. // Copyright (c) 2014年 lishujun. All r ...