CF898B.Proper Nutrition

普及-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Vasya has n burles. One bottle of Ber-Cola costs a burles and one Bars bar costs b burles. He can buy any non-negative integer number of bottles of Ber-Cola and any non-negative integer number of Bars bars.

Find out if it's possible to buy some amount of bottles of Ber-Cola and Bars bars and spend exactly n burles.

In other words, you should find two non-negative integers x and y such that Vasya can buy x bottles of Ber-Cola and y Bars bars and x·a + y·b = n or tell that it's impossible.

瓦西娅有 nn 卢布。一瓶 Ber-Cola 售价为 aa 卢布,一块 Bars 巧克力售价为 bb 卢布。他可以购买任意非负整数瓶的 Ber-Cola 和任意非负整数块的 Bars 巧克力。

请判断:是否存在一种购买方案,使得他恰好花费 nn 卢布。

换言之,你需要找出两个非负整数 xx 和 yy,使得瓦西娅能购买 xx 瓶 Ber-Cola 和 yy 块 Bars 巧克力,并满足 x⋅a+y⋅b=nx \cdot a + y \cdot b = n;若不存在这样的 xx 和 yy,则判定为不可能。

输入格式

First line contains single integer n (1 ≤ n ≤ 10 000 000) — amount of money, that Vasya has.

Second line contains single integer a (1 ≤ a ≤ 10 000 000) — cost of one bottle of Ber-Cola.

Third line contains single integer b (1 ≤ b ≤ 10 000 000) — cost of one Bars bar.

第一行包含一个整数 nn(1≤n≤10 000 0001 \leq n \leq 10\,000\,000)—— Vasya 拥有的钱数。

第二行包含一个整数 aa(1≤a≤10 000 0001 \leq a \leq 10\,000\,000)—— 一瓶 Ber-Cola 的价格。

第三行包含一个整数 bb(1≤b≤10 000 0001 \leq b \leq 10\,000\,000)—— 一块 Bars 巧克力的价格。

输出格式

If Vasya can't buy Bars and Ber-Cola in such a way to spend exactly n burles print «NO» (without quotes).

Otherwise in first line print «YES» (without quotes). In second line print two non-negative integers x and y — number of bottles of Ber-Cola and number of Bars bars Vasya should buy in order to spend exactly n burles, i.e. x·a + y·b = n. If there are multiple answers print any of them.

Any of numbers x and y can be equal 0.

如果瓦西娅无法通过购买 Bars 和 Ber-Cola 恰好花费 $ n $ 卢布,则输出 «NO»(不带引号)。

否则,第一行输出 «YES»(不带引号);第二行输出两个非负整数 $ x $ 和 $ y $ —— 分别表示瓦西娅应购买的 Ber-Cola 瓶数和 Bars 巧克力棒数量,使得总花费恰好为 $ n $ 卢布,即满足 $ x \cdot a + y \cdot b = n $。若存在多个解,输出任意一个即可。

$ x $ 和 $ y $ 中的任意一个可以为 0。

输入输出样例

  • 输入#1

    7
    2
    3

    输出#1

    YES
    2 1
  • 输入#2

    100
    25
    10

    输出#2

    YES
    0 10
  • 输入#3

    15
    4
    8

    输出#3

    NO
  • 输入#4

    9960594
    2551
    2557

    输出#4

    YES
    1951 1949

说明/提示

In first example Vasya can buy two bottles of Ber-Cola and one Bars bar. He will spend exactly 2·2 + 1·3 = 7 burles.

In second example Vasya can spend exactly n burles multiple ways:

  • buy two bottles of Ber-Cola and five Bars bars;
  • buy four bottles of Ber-Cola and don't buy Bars bars;
  • don't buy Ber-Cola and buy 10 Bars bars.

In third example it's impossible to but Ber-Cola and Bars bars in order to spend exactly n burles.

在第一个例子中,瓦西娅可以购买两瓶伯可乐和一条巴尔斯巧克力棒,恰好花费 2⋅2 + 1⋅3 = 72·2 + 1·3 = 7 布尔币。

在第二个例子中,瓦西娅恰好花费 nn 布尔币的方式有多种:

  • 购买两瓶伯可乐和五条巴尔斯巧克力棒;
  • 购买四瓶伯可乐且不购买巴尔斯巧克力棒;
  • 不购买伯可乐且购买 10 条巴尔斯巧克力棒。

在第三个例子中,无法通过购买伯可乐和巴尔斯巧克力棒恰好花费 nn 布尔币。

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

首页