Codeforces 651A Joysticks 【贪心】
来源:互联网 发布:linux 进程调度ppt 编辑:程序博客网 时间:2024/05/01 10:52
题目链接:Codeforces 651A Joysticks
题意:给定两个数
贪心模拟搞就可以了,每次将较大的减
#include <iostream>#include <cstdio>#include <cstring>#include <cstdlib>#include <cmath>#include <algorithm>#include <vector>#include <queue>#include <map>#define CLR(a, b) memset(a, (b), sizeof(a))using namespace std;typedef long long LL;typedef pair<int, char> pii;const int MAXN = 1000+10;const int INF = 0x3f3f3f3f;void getmax(int &a, int b) {a = max(a, b); }void getmin(int &a, int b) {a = min(a, b); }int main(){ int x, y; cin >> x >> y; int ans = 0; while(1) { if(x > y) swap(x, y); if(x == 2 && y == 2) { ans++; break; } if(x == 1 && y == 2) { ans++; break; } if(x == 1 && y == 1) { break; } if(y & 1) { ans += y / 2; x += y / 2; y = 1; } else { ans += y / 2 - 1; x += y / 2 - 1; y = 2; } //cout << x << " " << y << endl; } cout << ans << endl; return 0;}
0 0
- codeforces 651A Joysticks【贪心】
- Codeforces 651A Joysticks 【贪心】
- codeforces--651A Joysticks(贪心)
- Codeforces 651A Joysticks【贪心】
- CodeForces 651 A.Joysticks(贪心)
- CodeForces 651A-Joysticks
- Codeforces 651A Joysticks
- 【CodeForces】[651A]Joysticks
- Codeforces 651A Joysticks
- codeforces 651A Joysticks
- CodeForces 651 A Joysticks
- CodeForces-651A. Joysticks
- CodeForces 651A Joysticks
- codeforces 651A Joysticks
- codeforces 651A A. Joysticks
- CodeForces 651A:Joysticks【模拟】
- 【CodeForces 651A】Joysticks 模拟
- CF 651A Joysticks 贪心/DP
- spring-data-redis 的序列化问题
- Hadoop-新增节点
- 数独程序
- A*算法可视化详解与实现
- LG 全系列手机 绕过BL锁 详细图文教程
- Codeforces 651A Joysticks 【贪心】
- 点击多个view 避免同时产生多个响应
- nginx优化 突破十万并发
- JavaFX设置面板不捕获鼠标事件(透明或不计算边界)
- 修复office 2007或2010安装程序找不到Proplas.ww/Proplsww.cab
- PHP中的几个特殊操作符
- cuda 7.5 不支持 ubuntu 15.10 的 gcc 5 编译器问题
- listView,gridView复用问题
- Maven的配置