关于摩尔投币
#include<bits/stdc++.h>
using namespace std;
int n, a, ans, cnt;
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n;
for(int i=1; i<=n; ++i) {
cin >> a;
if(cnt==0) ans=a;
a==ans?cnt++:cnt--;
}
cout << ans;
return 0;
}
link
玩一个诸侯争霸的游戏,每个人口出去干仗都能一对一跟对面同归于尽。
最后还有人活下来的国家就是胜利。
那就大混战呗,如果你超过人超过总人数的一半,最差所有人都联合起来对付你,你也能 win。
如果其他国家相互攻击,你也不亏,最后肯定你还是赢。