183 字
1 分钟
题解:AT_past202303_a シンプル石取りゲーム
AT_past202303_a シンプル石取りゲーム 题解
思路
首先考虑 的情况。当 为偶数时,后手获胜,因为后手取走了最后一块石子;而当 为奇数时,先手获胜,因为先手取走了最后一块石子。
同样,当 时,如果 是偶数,那么先手获胜,因为后手取走了最后一块石子;如果 是奇数,那么后手获胜,因为先手取走了最后一块石子。
那么我们只需要把每种情况输出即可。
Code
#include<bits/stdc++.h>using namespace std;#define int long longint n,s,t;string fi,se;signed main() { ios::sync_with_stdio(false),cin.tie(0),cout.tie(0); cin>>n>>s>>t; if (s==0) fi="Alice",se="Bob"; else fi="Bob",se="Alice"; if (t==0) { if (n%2==0) cout<<se; else cout<<fi; } else { if (n%2==0) cout<<fi; else cout<<se; } return 0;}题解:AT_past202303_a シンプル石取りゲーム
https://banglee13.github.io/posts/atpast202303a/分享文章
生成精美分享图或复制链接,与更多人分享本文。
继续阅读
换条路线
从其他文章中稳定抽取
最后更新于 ,距今已过 335 天
部分内容可能已过时