题解:P13975 [VKOSHP 2024] Two Scooters

题解:P13975 [VKOSHP 2024] Two Scooters

Link

设公司 \(\texttt{W}\) 乘踏板车的总费用为 \(W_{w}\),公司 \(\texttt{Y}\) 乘踏板车的总费用为 \(W_{y}\)

考虑计算。首先可知两公司每秒的费用分别为 \(c_1,c_2\),总时间为 \(t\)。则:

\[W_{w}=\left \lfloor \frac{60}{t} \right \rfloor \times 60 \cdot c_1 \]

其中 \(\left \lfloor \frac{60}{t} \right \rfloor\) 可以取整分钟数。

考虑求 \(W_{y}\)。有:

\[W_{w} = \left \lfloor \frac{(t \cdot c_2)+99}{100} \right \rfloor \cdot 100 \]

因为通过 \(t \cdot c_2\) 计算出总费用(单位为美分),现在要向上取整。上文中的 \(\left \lfloor \frac{(t \cdot c_2)+99}{100} \right \rfloor\) 实现了向上取整的功能。其可以向上取整到最近的 \(100\) 的倍数。

取最小值即可。

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll t,c1,c2,ans,d,h;
int main(){
	cin>>t>>c1>>c2;
	d=(t/60)*60*c1;
	h=((t*c2)+99)/100*100;
	ans=min(d,h);
	cout<<ans;
}
posted @ 2025-09-07 21:42  M1_Byte  阅读(7)  评论(0)    收藏  举报