菜单 学习猿地 - LMONKEY

VIP

开通学习猿地VIP

尊享10项VIP特权 持续新增

知识通关挑战

打卡带练!告别无效练习

接私单赚外块

VIP优先接,累计金额超百万

学习猿地私房课免费学

大厂实战课仅对VIP开放

你的一对一导师

每月可免费咨询大牛30次

领取更多软件工程师实用特权

入驻
127
0

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

原创
05/13 14:22
阅读数 49300

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;
	}
}

发表评论

0/200
127 点赞
0 评论
收藏
为你推荐 换一批