Playing Cubes
来源:互联网 发布:单片机原理与应用答案 编辑:程序博客网 时间:2024/05/22 03:16
Playing Cubes
Petya and Vasya decided to play a little. They found n red cubes andm 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 haven + 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 andm(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 Input
3 1
2 1
2 4
3 2
Hint
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
/*********************************************** * Author: fisty * Created Time: 2015/2/6 20:25:59 * File Name : 5_B.cpp *********************************************** */#include <iostream>#include <cstring>#include <deque>#include <cmath>#include <queue>#include <stack>#include <list>#include <map>#include <set>#include <string>#include <vector>#include <cstdio>#include <bitset>#include <algorithm>using namespace std;#define Debug(x) cout << #x << " " << x <<endl#define Memset(x, a) memset(x, a, sizeof(x))const int INF = 0x3f3f3f3f;typedef long long LL;typedef pair<int, int> P;#define FOR(i, a, b) for(int i = a;i < b; i++) int main() { //freopen("in.cpp", "r", stdin); cin.tie(0); ios::sync_with_stdio(false); int n, m; cin >> n >> m; if(n > m) swap(n, m); cout << m - 1 << " " << n << endl; return 0;}
- Playing Cubes
- B. Playing Cubes
- EOJ 1864 Playing With Cubes
- CodeForces 257B Playing Cubes
- eoj1854 Playing With Cubes 二分图最大匹配
- Marching Cubes
- Marching Cubes
- Colored Cubes
- Risky cubes
- Perfect Cubes
- Colored Cubes
- Colored Cubes
- poj1543Perfect Cubes
- Perfect Cubes
- Marching Cubes
- Perfect Cubes
- Cubes UVA
- Marching Cubes
- Form界面的各组件的工作原理---中介者模式
- 深入浅出Linux工具与编程(socket 函数)
- 最新 unity 血条的另类制作-伤害减血加血自动回血
- 解决FTPClient linux 下载文件小于实际文件,线程挂起等问题
- iOS 上的蓝牙框架 - Core Bluetooth for iOS [译]
- Playing Cubes
- 某个UIView控件单独进行截图
- Masonry介绍与使用实践:学习Masonry写Autolayout
- 关于游戏的物理引擎
- EditText其最重要的一个属性是 android:inputType
- Android 带你从源码的角度解析Scroller的滚动实现原理
- 邮件服务实现
- linux文件属性详细说明
- 开始学习java4 线程线程