这题中的答案是怎么得出来的???急救!!

Cql_liliang 2011-12-10 03:18:12
Description
Our jeep is in the desert and we have a hard task: First we must reach a point which is N kilometers away from our camp, and then return to our camp. The terrain is tough, the car is old, and it seems like the fuel flows out, and because of this on every kilometer travelled, one litre of fuel is spent. But the jeep only has fuel tank with total capacity of M < N litres. On other hand, there is unlimited amount of fuel at our camp, and there are empty fuel tanks everywhere in the desert, these fuel tanks are large enough. When the jeep is passing near these fuel tanks, it can leave unlimited amount of fuel to them, or take unlimited amount of fuel from them to the jeep’s fuel tank.
Write a program which calculates the minimum amount of fuel in litres which is needed to reach the destination point and return to home.

Input
The input consists of multiple test cases.
The first line contains a number T, the number of the cases.
In the next T lines, every line contains two integers N and M. It is known that 5*M >= N > 0.(N <= 32000).


Output
For each test, write a single line contains the result (the minimum litres of fuel, eventually rounded up), must be written on the only line of output.


Sample Input
3
1000 2000
3000 1000
32000 6400

Sample Output
2000
226009
79145396

//5*M >= N 有什么用???
...全文
110 1 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
caozl 2011-12-10
  • 打赏
  • 举报
回复
大概想了一下 感觉It is known that 5*M >= N > 0.(N <= 32000).

这两个条件是为了防止数据溢出的。 如果没有这个限制,可能用long就不安全了

65,187

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧