HDOJ 1846 Brave Game - 博弈入门

题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1846

经典基础博弈,首先面对(m+1)的人一定会输,依次往后推即可;

 1 #include<iostream>
 2 using namespace std;
 3 
 4 #define LL long long
 5 int T, n, m;
 6 
 7 int main()
 8 {
 9     cin>>T;
10     while(T--) {
11         cin>>n>>m;
12         if(n>m && !(n%(m+1))) cout<<"second"<<endl;
13         else cout<<"first"<<endl;
14     }
15     
16     return 0;
17 }

猜你喜欢

转载自www.cnblogs.com/liubilan/p/9496789.html