题目很长,但是意思就是给你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. django 之(三) --- 认证|权限

    用户模块 登陆注册1:Django2.0  [ 1:N ] user/url.py from django.urls import path from user.views0 import UserT ...

  2. WIN10家庭版添加"本地安全策略"

    新建文本文件 输入一下命令 @echo off pushd "%~dp0" dir /b C:\Windows\servicing\Packages\Microsoft-Windo ...

  3. Vue.js 关于双向绑定的一些实现细节

    Vue.js 是采用 Object.defineProperty 的 getter 和 setter,并结合观察者模式来实现数据绑定的. 当把一个普通 Javascript 对象传给 Vue 实例来作 ...

  4. eNSP——配置通过FTP进行文件操作

    原理: FTP (File Transfer Protocol,文件传输协议)是在TCP/IP网络和Internet.上最早使用的协议之-,在TCP/IP协议族中属于应用层协议,是文件传输的Inter ...

  5. Beta冲刺博客

    这个作业属于哪个课程 当然是属于程序分析与设计呀 这个作业要求在哪里 在这儿 团队名称 六扇门编程小组(团队博客) 这个作业的目标 完成为期两周的β版本冲刺 1.团队信息 姓名 学号 曹欢(组长) 2 ...

  6. 《MIT 6.828 Homework 1: boot xv6》解题报告

    本作业的网站链接:MIT 6.828 Homework 1: boot xv6 问题 Exercise: What is on the stack? While stopped at the abov ...

  7. 【USB】struct usb_device_id 结构体详解

    struct usb_device_id { /* which fields to match against? */ __u16 match_flags; //说明使用哪种匹配方式 /* Used ...

  8. OkHttp3 + retrofit2 封装

    0.下载文件 1.gradle 添加 compile 'com.squareup.retrofit2:retrofit:2.1.0'compile 'com.squareup.retrofit2:co ...

  9. StoneTab标签页CAD插件 3.2.3

    //////////////////////////////////////////////////////////////////////////////////////////////////// ...

  10. RabbitMq 开始<一>

    power shell 执行: dotnet new console --name Send mv Send/Program.cs Send/Send.cs dotnet new console -- ...