当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

6071:Lazy Running

题目描述
In HDU, you have to run along the campus for 24 times, or you will fail in PE. According to the rule, you must keep your speed, and your running distance should not be less than $K$ meters.

There are $4$ checkpoints in the campus, indexed as $p_1,p_2,p_3$ and $p_4$. Every time you pass a checkpoint, you should swipe your card, then the distance between this checkpoint and the last checkpoint you passed will be added to your total distance.

The system regards these $4$ checkpoints as a circle. When you are at checkpoint $p_i$, you can just run to $p_{i-1}$ or $p_{i+1}$($p_1$ is also next to $p_4$). You can run more distance between two adjacent checkpoints, but only the distance saved at the system will be counted.





Checkpoint $p_2$ is the nearest to the dormitory, Little Q always starts and ends running at this checkpoint. Please write a program to help Little Q find the shortest path whose total distance is not less than $K$.
输入解释
The first line of the input contains an integer $T(1\leq T\leq15)$, denoting the number of test cases.

In each test case, there are $5$ integers $K,d_{1,2},d_{2,3},d_{3,4},d_{4,1}(1\leq K\leq 10^{18},1\leq d\leq 30000)$, denoting the required distance and the distance between every two adjacent checkpoints.
输出解释
For each test case, print a single line containing an integer, denoting the minimum distance.
输入样例
1
2000 600 650 535 380
输出样例
2165
提示
The best path is 2-1-4-3-2.
来自杭电HDUOJ的附加信息
Recommend liuyiding

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-6071

最后修改于 2020-10-25T23:28:04+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 524288/524288K(Java/Others)