题目很长,但是意思就是给你n,A,B,C,D

n表示有n个城市 A是飞机的重量 B是一个常数表示转机代价 C是单位燃油的价格 D是一个常数

假设一个点到另外一个点的距离为整数L 起飞前的油量为f  则在这途中每飞行一单位距离 就花费(f+A)/D的燃油

#include <bits/stdc++.h>
typedef long long ll;
typedef long double lb;
using namespace std;
const int MAXN=,MAXM=;
int to[MAXM << ], nxt[MAXM << ], Head[MAXN], ed = ;
lb cost[MAXM << ];
int n;
inline void addedge(int u, int v, lb c) {
to[++ed] = v;
nxt[ed] = Head[u];
Head[u] = ed;
cost[ed] = c;
}
struct HeapNode {
int u;
lb d;
bool operator < (const HeapNode& rhs) const {
return d > rhs.d;
}
} zz;
lb mindist[MAXN];
bool vis[MAXN];
priority_queue<HeapNode> que;
void Hijkstra(int s) {
for (int i = ; i <= n; i++) {
mindist[i] = 4000000000000000000.0;
}
mindist[s] = 0.0;
memset(vis, , sizeof(vis));
zz.d = , zz.u = s;
que.push(zz);
while (!que.empty()) {
HeapNode x = que.top();
que.pop();
int u = x.u;
if (vis[u] || mindist[u] != x.d) {
continue;
}
vis[u] = true;
for (int v, i = Head[u]; i; i = nxt[i]) {
v = to[i];
if (mindist[v] > mindist[u] + cost[i]) {
mindist[v] = mindist[u] + cost[i];
//p[v]=u;
zz.d = mindist[v], zz.u = v;
que.push(zz);
}
}
}
}
void init(int x) {
ed = ;
for (int i = ; i <= x; i++) {
Head[i] = ;
}
}
struct node {
ll x, y;
} P[MAXN];
int main() {
int TC;
scanf("%d", &TC);
while (TC--) {
ll A, B, C, D;
scanf("%d %lld %lld %lld %lld", &n, &A, &B, &C, &D);
init(n);
for (int i = ; i <= n; i++) {
scanf("%lld %lld", &P[i].x, &P[i].y);
}
for (int i = ; i <= n; i++) {
for (int j = i + ; j <= n; j++) {
ll ax = abs(P[i].x - P[j].x);
ll ay = abs(P[i].y - P[j].y);
ll dis = ax * ax + ay * ay;
dis = ceil(sqrt(dis));
lb c = (pow((lb)D / (D - 1.0), dis) - 1.0) * A * C + B;
addedge(i,j,c),addedge(j,i,c);
}
}
Hijkstra();
printf("%.10Lf\n", mindist[n]);
}
return ;
}

Gym - 102141D 通项公式 最短路的更多相关文章

  1. Gym 101873C - Joyride - [最短路变形][优先队列优化Dijkstra]

    题目链接:http://codeforces.com/gym/101873/problem/C 题意: 这是七月的又一个阳光灿烂的日子,你决定和你的小女儿一起度过快乐的一天.因为她真的很喜欢隔壁镇上的 ...

  2. Gym - 100625J Jailbreak 最短路+搜索

    http://codeforces.com/gym/100625/attachments/download/3213/2013-benelux-algorithm-programming-contes ...

  3. GYM 101933D(最短路、二分、dp)

    要点 非要先来后到暗示多源最短路,求最小的最大值暗示二分 二分内部的check是关键,dp处理一下,\(dp[i]\)表示第\(i\)笔订单最早何时送达,如果在ddl之前到不了则\(return\ 0 ...

  4. POJ 3635 - Full Tank? - [最短路变形][手写二叉堆优化Dijkstra][配对堆优化Dijkstra]

    题目链接:http://poj.org/problem?id=3635 题意题解等均参考:POJ 3635 - Full Tank? - [最短路变形][优先队列优化Dijkstra]. 一些口胡: ...

  5. 【最短路】NEERC15 F Froggy Ford(2015-2016 ACM-ICPC)(Codeforces GYM 100851)

    题目链接: http://codeforces.com/gym/100851 题目大意: 一只青蛙跳过宽为W的河,河中游N个石头,坐标xi,yi,现在往河中间添加一个石头,使得每次跳跃的最大的距离最小 ...

  6. 【最短路】BAPC2014 B Button Bashing (Codeforces GYM 100526)

    题目链接: http://codeforces.com/gym/100526 http://acm.hunnu.edu.cn/online/?action=problem&type=show& ...

  7. Codeforces Gym 100338C Important Roads 最短路+Tarjan找桥

    原题链接:http://codeforces.com/gym/100338/attachments/download/2136/20062007-winter-petrozavodsk-camp-an ...

  8. Gym - 100625D Destination Unknown 最短路

    http://codeforces.com/gym/100625/attachments/download/3213/2013-benelux-algorithm-programming-contes ...

  9. Codeforces Gym 101630J Travelling from Petersburg to Moscow (最短路)

    题目链接 http://codeforces.com/gym/101630/attachments 题解 zyb学长的题. 先枚举第\(k\)大的边权,设其边权为\(x\),然后把每条边边权减掉\(x ...

随机推荐

  1. LAG函数实现环比

    ,)OVER(ORDER BY 年月) 环比金额 from( 年, 季度, 年月 ,SUM(金额本位币) 金额 FROM ( SELECT * FROM [dbo].[T_output] ) cb_v ...

  2. cent7配置阿里yum源

    阿里云Linux安装镜像源地址:http://mirrors.aliyun.com/CentOS系统更换软件安装源第一步:备份你的原镜像文件,以免出错后可以恢复.mv /etc/yum.repos.d ...

  3. 《MIT 6.828 Homework 2: Shell》解题报告

    Homework 2的网站链接:MIT 6.828 Homework 2: shell 题目 下载sh.c文件,在文件中添加相应代码,以支持以下关于shell的功能: 实现简单shell命令,比如ca ...

  4. zabbix监控mysql主从同步和延迟

    https://blog.csdn.net/natmazz/article/details/90581490 https://www.cnblogs.com/01-single/p/10602610. ...

  5. java动态更新枚举类

    工作中遇到需要对枚举类的值进行动态更新 手动改不现实也不方便 现记录下来方便以后学习使用 1.在工程utils包中添加动态更新枚举类得工具类(根据自己得项目,放到指定位置调用就可以) 2.一开始陷入了 ...

  6. C语言字符串替换

    void exchg(char * str) { if(str == NULL) return; int len = strlen(str); char tmp; for(int i=0,j=len- ...

  7. [游戏复刻] Super Mario Brothers(1985. Famicom)

    10/20 第一版,导入了地图,设置了碰撞块

  8. Centos安装elasticsearch,php连接使用

    一.下载安装JAVA 下载地址:https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html ...

  9. 【Python基础】06_Python中的函数

    1.函数的定义 def 函数名(): 函数封装的代码 …… 注:函数前后应该保留两个空行 2.函数的使用 直接使用函数名()调用函数块. def say_hello(): print("He ...

  10. Pygame小游戏练习二

    @Python编程从入门到实践 Python项目练习 四.创建Ship类 建立ship.py,创建Ship类,管理飞船行为. # ship.py import pygame class Ship(): ...