题目链接https://leetcode.cn/problems/total-distance-traveled/?envType=daily-question&envId=2024-04-25
简单题,看代码思考一下即可理解
class Solution {
public int distanceTraveled(int mainTank, int additionalTank) {
int res = 0;
while (mainTank >= 5) {
int t = mainTank / 5;
res += t * 50;
mainTank %= 5;
t = Math.min(t, additionalTank);
additionalTank -= t;
mainTank += t;
}
return res + mainTank * 10;
}
}