CF1214A.Optimal Currency Exchange

普及/提高-

通过率:0%

时间限制:1.50s

内存限制:512MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Andrew was very excited to participate in Olympiad of Metropolises. Days flew by quickly, and Andrew is already at the airport, ready to go home. He has nn rubles left, and would like to exchange them to euro and dollar bills. Andrew can mix dollar bills and euro bills in whatever way he wants. The price of one dollar is dd rubles, and one euro costs ee rubles.

Recall that there exist the following dollar bills: 11, 22, 55, 1010, 2020, 5050, 100100, and the following euro bills — 55, 1010, 2020, 5050, 100100, 200200 (note that, in this problem we do not consider the 500500 euro bill, it is hard to find such bills in the currency exchange points). Andrew can buy any combination of bills, and his goal is to minimize the total number of rubles he will have after the exchange.

Help him — write a program that given integers nn, ee and dd, finds the minimum number of rubles Andrew can get after buying dollar and euro bills.

安德鲁非常兴奋地参加了大都市奥林匹克竞赛。时光飞逝,安德鲁已抵达机场,准备回家。他手头还剩 nn 卢布,希望将这些钱兑换成美元和欧元纸币。安德鲁可以任意组合美元和欧元纸币。1 美元的价格为 dd 卢布,1 欧元的价格为 ee 卢布。

回忆一下,目前流通的美元纸币面额有:11、22、55、1010、2020、5050、100100;欧元纸币面额有:55、1010、2020、5050、100100、200200(注意:本题中不考虑 500500 欧元纸币,因为货币兑换点很难找到这种面额的纸币)。安德鲁可以购买任意组合的纸币,其目标是使兑换后剩余的卢布总数最小。

请帮助他——编写一个程序,输入整数 nn、ee 和 dd,输出安德鲁在购买美元和欧元纸币后所能得到的最少剩余卢布数。

输入格式

The first line of the input contains one integer nn (1≤n≤1081 \leq n \leq 10^8) — the initial sum in rubles Andrew has.

The second line of the input contains one integer dd (30≤d≤10030 \leq d \leq 100) — the price of one dollar in rubles.

The third line of the input contains integer ee (30≤e≤10030 \leq e \leq 100) — the price of one euro in rubles.

输入的第一行包含一个整数 nn(1≤n≤1081 \leq n \leq 10^8)——安德鲁最初拥有的卢布金额。

输入的第二行包含一个整数 dd(30≤d≤10030 \leq d \leq 100)——一美元对应的卢布价格。

输入的第三行包含一个整数 ee(30≤e≤10030 \leq e \leq 100)——一欧元对应的卢布价格。

输出格式

Output one integer — the minimum number of rubles Andrew can have after buying dollar and euro bills optimally.

输出一个整数——安德鲁在最优地购买美元和欧元纸币后所拥有的最少卢布数。

输入输出样例

  • 输入#1

    100
    60
    70

    输出#1

    40
  • 输入#2

    410
    55
    70

    输出#2

    5
  • 输入#3

    600
    60
    70

    输出#3

    0

说明/提示

In the first example, we can buy just 11 dollar because there is no 11 euro bill.

In the second example, optimal exchange is to buy 55 euro and 11 dollar.

In the third example, optimal exchange is to buy 1010 dollars in one bill.

在第一个例子中,我们只能购买 11 美元,因为没有面值为 11 欧元的纸币。

在第二个例子中,最优的兑换方式是购买 55 欧元和 11 美元。

在第三个例子中,最优的兑换方式是一次性购买 1010 美元(使用一张纸币)。

输入解题思路,AI测评打分。不知道怎么写?

首页