题目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. iOS中常用技术链接

    1.弹幕技术 http://www.jianshu.com/p/f39b8abc8008 2.通过CAGradientLayer制作渐变色效果 http://blog.it985.com/7986.h ...

  2. 小知识 Vector的枚举 和foreach的用法

    package com.java.c.votetor.www; import java.util.Enumeration;import java.util.Iterator;import java.u ...

  3. frameset标签代码实现网站跳转

    js代码1: document.writeln("<frameset rows=\"0, *\">"); document.writeln(&quo ...

  4. 精通 Oracle+Python,第 9 部分:Jython 和 IronPython — 在 Python 中使用 JDBC 和 ODP.NET

    成功的编程语言总是会成为顶级开发平台.对于 Python 和世界上的两个顶级编程环境 Java 和 Microsoft .NET 来说的确如此. 虽然人们因为 Python 能够快速组装不同的软件组件 ...

  5. DATE 使用

    DATE 使用 标签(空格分隔): SHELL 使用shell处理文本时经常要使用date,但各种参数经常忘,记录在此: #date 获取当前时间 #date -d "-1 week&quo ...

  6. 利用java实现一个简单的远程监控程序

    一般的远程监控软件都是用c或者c++等语言开发的,而使用java如何来实现相同的功能呢. 首先我们先介绍一下一个简单的远程监控程序的实现原理. 功能一,远程屏幕监视 (1) 必须要有监控端与被监控端, ...

  7. 将小度WiFi改造为无线网卡(小度WiFi能够接收WiFi信号)

    安装官方的小度WiFi的驱动器,只能让它当做无线信号的发射装置,但是我想通过小度WiFi让我的台式电脑能都接收无线信号,于是经过一番折腾终于成功了.我的是win7. 小度WiFi无法接受无线信号,不能 ...

  8. adb的logcat使用

    预备:安装刷机精灵,实用工具->adb命令行 1. 对于多机设备,首先使用adb devices来获知设备名称: 2. 将log输出到电脑:adb –s [设备名称] shell logcat ...

  9. SendMail

    public ActionResult SendMail() { MailMessage mss = new MailMessage(); mss.From = new MailAddress(&qu ...

  10. LightOj_1079 Just another Robbery

    题目链接 题意: 抢银行(这个背景最爱了), 有n家银行, 每家银行抢劫被抓的概率是p[i],你认为当你被抓的概率低于P的时候是安全的. 问, 你最多能抢劫到多少money. 思路: 抽象成背包问题, ...