标签:个人 end name == 博弈 ios win cstring ring
一堆石子N个 每个人最少取P个 最多取Q个 最后取光的人输 问谁赢
X=N%(P+Q) X=0则先手取Q个必胜 X<=P则后手胜 X>P则先手取P个必胜
#include <iostream> #include <cstdio> #include <string> #include <cstring> using namespace std; int main() { int n, p, q; while ( scanf ( "%d%d%d", &n, &p, &q ) != EOF ) { int t = n % ( p + q ); if ( t == 0 ) { cout << "WIN" << endl; } else if ( t <= p ) { cout << "LOST" << endl; } else { cout << "WIN" << endl; } } }
标签:个人 end name == 博弈 ios win cstring ring
原文地址:https://www.cnblogs.com/Aragaki/p/11643497.html