2020-3-20-3 AtCoder ACM训练题代码

本文记录了作者在AtCoder训练中解决ACM问题的经历,问题涉及找到一个商品原价,使得在8%和10%两种税率下,消费税分别为A和B日元。通过建立不等式求解问题,最终实现代码解决并讨论了避免无效数据的方法。
摘要由CSDN通过智能技术生成

有好多天没做AtCoder的题了,所以今天就练了一下,然后终于实现了一的突破,开始能做出第三题了,虽说只是Beginner,但是也算有点进步了,下面是具体过程:

**C - Tax Increase /**

Time Limit: 2 sec / Memory Limit: 1024 MB

Score : 300 points
Problem Statement

Find the price of a product before tax such that, when the consumption tax rate is 8
percent and 10 percent, the amount of consumption tax levied on it is A yen and B yen, respectively. (Yen is the currency of Japan.)

Here, the price before tax must be a positive integer, and the amount of consumption tax is rounded down to the nearest integer.

If multiple prices satisfy the condition, print the lowest such price; if no price satisfies the condition, print -1.
Constraints
1≤A≤B≤100
A and B are integers.
首先:我们先来理解这个题目:
就是要找一个数,假设它是x,那么0.08x的向下取整就是A,它的0.1x的向下取整就是B。
那么我们先来确定x的范围,A的12.5倍(即A/0.08

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值