Restoring Number

Pavel had two positive integers a and b. He found their sum s and greatest common divisor g, and forgot a and b after that. Help him to restore the original numbers.

Input

A single line contains two integers s and g (1 ≤ s ≤ 109, 1 ≤ g ≤ 109) — sum and greatest common divisor of the numbers a and b.

Output

If Pavel made a mistake and there are no such numbers a and b, output a single number  - 1.

Otherwise, output two positive integers a and b on a single line, separated by a space. If there are multiple possible solutions, output any of them.

Examples

input

Copy

6 2

output

4 2

input

Copy

7 2

output

-1

 

题意:求两个数,已知他们的和以及他们的公约数

推导: 假设 两个数为 12 8 则和为20,公约数为4

12=3*4 8=2*4 3和2互质,所以最大公约数为1 故20=(3+2)*4  此时如果存在的话  那gcd(4,20-4)=gcd(4,4*4)的公约数肯定也为4,所以只需要判断gcd(s,g)==g?存在:不存在  如果存在

如果存在就把公约数作为一个数,因为此时其前面的系数为1,与其他数都互质

 

#include <iostream>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>


using namespace std;
typedef long long ll;


int gcd(int x,int y)
{
    return y==0?x:gcd(y,x%y);
}
int main()
{
    int s,g;
    while(~scanf("%d%d",&s,&g))
    {
        if(gcd(s-g,g)==g&&s!=g)
        {
            printf("%d %d\n",s-g,g);
        }
        else puts("-1");
    }
    return 0;
}

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值