Description
Petya and Vasya decided to play a little. They found n red cubes and m blue cubes. The game goes like that: the players take turns to choose a cube of some color (red or blue) and put it in a line from left to right (overall the line will have n + m cubes). Petya moves first. Petya's task is to get as many pairs of neighbouring cubes of the same color as possible. Vasya's task is to get as many pairs of neighbouring cubes of different colors as possible.
The number of Petya's points in the game is the number of pairs of neighboring cubes of the same color in the line, the number of Vasya's points in the game is the number of neighbouring cubes of the different color in the line. Your task is to calculate the score at the end of the game (Petya's and Vasya's points, correspondingly), if both boys are playing optimally well. To "play optimally well" first of all means to maximize the number of one's points, and second — to minimize the number of the opponent's points.
Input
The only line contains two space-separated integers n and m (1 ≤ n, m ≤ 10^5) — the number of red and blue cubes, correspondingly.
Output
On a single line print two space-separated integers — the number of Petya's and Vasya's points correspondingly provided that both players play optimally well.
Sample Input
3 1
2 4
Sample Output
2 1
3 2
解析
列了几组数据发现,Petya的最终得分就是max(n,m)-1,Vasya最终得分就是min(n,m)
代码
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
int n,m;
while(~scanf("%d%d",&n,&m))
{
int dif=min(n,m);
int same=max(n,m)-1;
printf("%d %d\n",same,dif);
}
return 0;
}