Codeforces Round #596 (Div. 2, based on Technocup 2020 Elimination Round 2) A. Forgetting Things 水题

A. Forgetting Things

Kolya is very absent-minded. Today his math teacher asked him to solve a simple problem with the equation 𝑎+1=𝑏 with positive integers 𝑎 and 𝑏, but Kolya forgot the numbers 𝑎 and 𝑏. He does, however, remember that the first (leftmost) digit of 𝑎 was 𝑑𝑎, and the first (leftmost) digit of 𝑏 was 𝑑𝑏.

Can you reconstruct any equation 𝑎+1=𝑏 that satisfies this property? It may be possible that Kolya misremembers the digits, and there is no suitable equation, in which case report so.

Input

The only line contains two space-separated digits 𝑑𝑎 and 𝑑𝑏 (1≤𝑑𝑎,𝑑𝑏≤9).

Output

If there is no equation 𝑎+1=𝑏 with positive integers 𝑎 and 𝑏 such that the first digit of 𝑎 is 𝑑𝑎, and the first digit of 𝑏 is 𝑑𝑏, print a single number −1.

Otherwise, print any suitable 𝑎 and 𝑏 that both are positive and do not exceed 109. It is guaranteed that if a solution exists, there also exists a solution with both numbers not exceeding 109.

Examples

input
1 2
output
199 200

题意

现在告诉你a+1=b,现在给你a和b的最高位,然后让你输出可能的a和b是什么,如果无解输出-1

题解

可能性就3种,其他都无解,枚举这种可能性就好。

代码

#include<iostream>
using namespace std;

int main(){
	int a,b;
	cin>>a>>b;
	if(b==1&&a==9){
		cout<<"9 10"<<endl;
	}else if(b-a==1){
		cout<<a<<" "<<b<<endl;
	}else if(a==b){
		cout<<a<<"1 "<<b<<"2"<<endl;
	}else{
		cout<<"-1"<<endl;
	}
}
posted @ 2019-11-01 14:36  qscqesze  阅读(258)  评论(0编辑  收藏  举报