【CodeForces 625A】Guest From the Past
The from Codeforces
2023-09-11 14:19:25 时间
题意
一升奶可以花费a元,也可以用b元买然后获得c元,一开始有n元,求最多买多少升奶。
分析
贪心,如果b-c<a,且n≥b,那就买b元的,n先减去b再看看够买多少瓶,然后再+1瓶,余款再购买a元的。
代码
#include<cstdio> unsigned long long n,a,b,c,ans; int main(){ scanf("%lld%lld%lld%lld",&n,&a,&b,&c); if(b-c<a && n>=b){ ans=(n-b)/(b-c)+1; n-=(b-c)*ans; } ans+=n/a; printf("%lld",ans); return 0; }
相关文章
- Tian Ji -- The Horse Racing 2287 (好题 数学逻辑)
- delete some elements from the head of slice without new memory
- ArcGIS Server启动服务报:ERROR: Unable to start Xvfb on any port in the range 6600 - 6619
- [Tools Vim] Open Files into Vim from the Terminal as buffers, splits, and tabs
- [Javascript Crocks] Recover from a Nothing with the `alt` method
- [Typescript] Tips: Create your own 'objectKeys' function using generics and the 'keyof' operator
- [Cloud Architect] 12. Defensive Security in the Cloud
- Intuitive explanation of a definition of the Fisher information
- Could not find com.android.tools.build:gradle:4.2.2. Searched in the following locations: - https:
- The specified Android SDK Build Tools version (29.0.0) is ignored, as it is below the minimum suppor
- 成功解决ERROR: Could not find a version that satisfies the requirement pyfm (from versions: 0.2, 0.2.1,
- 成功解决TypeError: Cannot cast array data from dtype('float64') to dtype('U32') according to the rule '
- 成功解决h5py_init_.py:26:FutureWarning: Conversion of the second argument of issubdtype from `float` to
- 成功解决h5py__init__.py:34: FutureWarning: Conversion of the second argument of issubdtype from `float
- EnvironmentNotWritableError: The current user does not have write permissions to the targe...
- PAT 1038 Recover the Smallest Number[dp][难]
- Error:The supplied javaHome seems to be invalid. I cannot find the java executable. Tried location:
- MySQL----JDBC无法连接数据库,报The driver has not received any packets from the server的解决办法
- 存在隐患 : 3 racks are required for the erasure coding policies: RS-6-3-1024k. The number of racks is on