链接:
https://codeforces.com/contest/1247/problem/A
题意:
Kolya is very absent-minded. Today his math teacher asked him to solve a simple problem with the equation a+1=b with positive integers a and b, but Kolya forgot the numbers a and b. He does, however, remember that the first (leftmost) digit of a was da, and the first (leftmost) digit of b was db.
Can you reconstruct any equation a+1=b that satisfies this property? It may be possible that Kolya misremembers the digits, and there is no suitable equation, in which case report so.
思路:
特判9 1,其他的照着搞。
代码:
//#include <iostream>
//#include <fstream>
//#include <process.h>
//#include "ch08/ch08Func.cpp"
#include <bits/stdc++.h>
typedef long long LL;
using namespace std;
int main()
{
ios::sync_with_stdio(false);
int a, b;
cin >> a >> b;
if (a == b)
{
cout << a << '1' << ' ' << b << '2' << endl;
return 0;
}
if (a == 9 && b == 1)
{
cout << 9 << ' ' << 10 << endl;
return 0;
}
if (a > b || b-a > 1)
{
cout << -1 << endl;
return 0;
}
cout << a << '9' << ' ' << b << '0' << endl;
return 0;
}