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 𝑑𝑏.ios

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.git

Input

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

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.this

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.spa

Examples

input
1 2
output
199 200code

題意

如今告訴你a+1=b,如今給你a和b的最高位,而後讓你輸出可能的a和b是什麼,若是無解輸出-1ci

題解

可能性就3種,其餘都無解,枚舉這種可能性就好。rem

代碼

#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;
    }
}
相關文章
相關標籤/搜索