B. Proper Nutrition
 
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

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.

Input

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.

Output

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.

Examples
input
7
2
3
output
YES
2 1
input
100
25
10
output
YES
0 10
input
15
4
8
output
NO
input
9960594
2551
2557
output
YES
1951 1949
Note

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.

代码:

 1 #include<iostream>
2 #include<cstring>
3 #include<cstdio>
4 #include<cmath>
5 #include<algorithm>
6 using namespace std;
7 typedef long long ll;
8 int main(){
9 ll n,a,b;
10 while(~scanf("%lld",&n)){
11 scanf("%lld%lld",&a,&b);
12 int flag=0;ll cnt,num;
13 for(int i=0;;i++){
14 num=n-i*a;
15 if(num<0)break;
16 if(num%b==0){flag=1;cnt=i;break;}
17 }
18 if(flag==1){
19 printf("YES\n");
20 cout<<cnt<<" "<<num/b<<endl;
21 }
22 else cout<<"NO"<<endl;
23 }
24 return 0;
25 }

最新文章

  1. 在DBeaver中phoenix查询报错:org.apache.phoenix.exception.PhoenixIOException: The system cannot find the path specified
  2. android 之 surfaceView和普通View的重绘使用
  3. 使用Servlet实现图片下载
  4. android 学习运用海马模拟器教程与android环境的搭建
  5. 【MySQL】MySQL复制表结构、表数据
  6. jq 弹出窗口
  7. 40个Java集合面试问题和答案【上】【转载】
  8. mobile js
  9. jsp 中对jar 包的引用
  10. C/S模式开发中如何利用WebBrowser控件制作导航窗体
  11. Java 笔试面试 基础篇 一
  12. Python3基础 frozenset() 创建一个不可更改的集合
  13. BZOJ:4826: [Hnoi2017]影魔
  14. 第一周C语言作业
  15. webservice之jax-rs实现方式
  16. LevelDB源码分析-Open
  17. oppo手机屏幕录制的详细操作技巧
  18. 清除redis缓存
  19. Dynamic CRM 2016 的备份/恢复/重新部署
  20. Visual Studio下运行PowerShell脚本自增小版本号并发布到Nuget服务器上

热门文章

  1. UVA - 753 A Plug for UNIX(网络流)
  2. Codeforces Round #459 (Div. 2):D. MADMAX(记忆化搜索+博弈论)
  3. loj2292 「THUSC 2016」成绩单
  4. MoveWindow() SetWindowPos()的区别与联系
  5. Python 拓展之推导式
  6. json对象中根据主键判断是否有重复数据
  7. Python面相对象之类里面常用的装饰器(3)
  8. HLG 1494网络 (求的割点数目)可做模板
  9. mybatis经验
  10. Threadlocal_笔记