B. Playing Cubes

time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

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 ≤ 105) — 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 test(s)
input
3 1
output
2 1
input
2 4
output
3 2
Note

In the first test sample the optimal strategy for Petya is to put the blue cube in the line. After that there will be only red cubes left, so by the end of the game the line of cubes from left to right will look as [blue, red, red, red]. So, Petya gets 2 points and Vasya gets 1 point.

If Petya would choose the red cube during his first move, then, provided that both boys play optimally well, Petya would get 1 point and Vasya would get 2 points.


解题说明:此题是一道博弈的题目,A,B两个人在一条线上摆放两种颜色的砖块,A的积分为相邻两块砖块颜色相同的数目,B的积分为不同的数目。每次A和B摆放时都选择对自己最优的策略。从简单的例子入手,就能发现A和B摆放顺序如下:红蓝蓝红蓝蓝红......,这种形式固定,故A和B的得分只与砖块数目相同,这样就找到了规律。


#include 
#include
#include
#include
#include
#include
using namespace std;

int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    if(n>m)    
	{
		printf("%d %d\n",n-1,m);
	}
	else
	{
		printf("%d %d\n",m-1,n);
	}
	return 0;
}


你可能感兴趣的:(AC路漫漫)