当前位置:网站首页>Circle Game
Circle Game
2022-07-19 23:31:00 【枉玊】
Circle Game
题意
有 n n n堆石子两个人轮流游戏,假设 A A A在 i i i操作了则 B B B下一次在 ( i + 1 ) % n + 1 (i+1)\% n+1 (i+1)%n+1的位置操作,每个人每次可以大于 1 1 1的任意大于 0 0 0的石子,当某个人无法操作则这个人输, A A A先手且从位置 1 1 1开始,问你两人均操作最优情况下谁赢
思路
- 贪心
如果 n n n是奇数, A A A必胜,因为 A A A把第 1 1 1堆都拿走,然后走一圈回来 B B B会在第 1 1 1堆操作这个时候没法操作了
如果 n n n是偶数,两个人能操作的位置是固定的 A A A只能在奇数位置轮流操作, B B B只能在偶数位置轮流操作,因此我们找到第一个最小是看是奇数还是偶数位置即可
Code
#include <bits/stdc++.h>
#define x first
#define y second
#define debug(x) cout<<#x<<":"<<x<<endl;
using namespace std;
typedef long double ld;
typedef long long LL;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
typedef unsigned long long ULL;
const int N = 1e5 + 10, M = 2 * N, INF = 0x3f3f3f3f, mod = 1e9 + 7;
const double eps = 1e-8, pi = acos(-1), inf = 1e20;
int dx[] = {
-1, 0, 1, 0}, dy[] = {
0, 1, 0, -1};
int h[N], e[M], ne[M], w[M], idx;
void add(int a, int b, int v = 0) {
e[idx] = b, w[idx] = v, ne[idx] = h[a], h[a] = idx ++;
}
int n, m, k;
LL a[N];
int main() {
ios::sync_with_stdio(false), cin.tie(0);
int T;
cin >> T;
while (T -- ) {
cin >> n;
LL s1 = 2e9;
idx = 0;
for (int i = 1; i <= n; i ++) {
cin >> a[i];
if (a[i] < s1) s1 = a[i], idx = i;
}
if (n & 1) cout << "Mike\n";
else {
if (idx & 1) cout << "Joe\n";
else cout << "Mike\n";
}
}
return 0;
}
边栏推荐
猜你喜欢
Application of GIS technology in the medical industry: using slice map publishing technology to solve the online browsing of dmetrix digital pathological slices
The savefig of Matplotlib must be before show
葡萄牙语金融财务词汇翻译
西门子低代码客户案例|跨越沟通壁垒,解决应用开发效能瓶颈
144. 二叉树的前序遍历
MySQL 19: database and table splitting practice
【ROS】话题基础使用
openvino模型学习-从模型转化流水线制作
多地市监部门展开冷饮抽检,钟薛高等产品均合格
These super easy-to-use browser plug-ins are unknown to many people
随机推荐
[ROS] use of roslaunch
These super easy-to-use browser plug-ins are unknown to many people
Ali P8 posted the salary slip in January. It really pierced my heart after reading it
Huawei wireless devices are configured with fast roaming between APs of the same service VLAN
股票开户网上办理的话安全吗。股票开户去哪里。
【大规模训练】transformer 中的张量模型并行
深度参与 openGauss Developer Day 2022,云和恩墨在多项活动中展风采
MySQL5.7 参数详解
.NET 设置Socket 对象的“TFO”快速打开连接选项(跨平台兼容的)
RuntimeError: CUDA error: an illegal memory access was encountered
[ROS] topic based use
I really can't roll
A combination idea of developing applet +app) with fluent
【Flink】聚合算子
【Flink】提交jar包到Flink集群并运行
[large scale training] tensor model parallelism in transformer
On demand introduction of antd + custom theme
fiddler 抓包显示 ERR_TUNNEL_CONNECTION_FAILED
Chengdu small products in 1998, joined a state-owned enterprise for two and a half years, and the salary exceeded 18K
Es6 - - promesse vs fonction "Callback Hell"