题解:P16108 「o.OI R-1」基础博弈练习题
首先我们站在先手的角度想想问题。
我们的目标是,我取完一次,对手就没法干了。
很容易想到,如果取到石子数目是序列中一个元素的整数倍,那么总石子数应该大于或者等于这个元素。
因此,我们先手如果能取,那么直接选择序列中最小的元素,取最多次,这样,对手面对的局面总石子数一定是小于最小项的,这样就没法取了。所以当
同样的道理,如果一开始就没法满足这个条件,先手直接卡死了,没法取。
代码如下:
#include <iostream>
#include <vector>
#include <algorithm>
int main()
{
int T;
std::cin >> T;
while (T--)
{
long long n, m;
std::cin >> n >> m;
std::vector<long long> a(m);
for (int i = 0; i < m; i++)
std::cin >> a[i];
if (n < *std::min_element(a.begin(), a.end()))
std::cout << "xwx" << std::endl;
else
std::cout << "Ciallo~" << std::endl;
}
}