打表找规律

 

 

 

 


#include <bits/stdc++.h>
using namespace std;
class Solution{
public:
string winner1(int n ){
if(0<=n && n<= 4) return (n==0 ||n==2 )?"hou":"xian";
int base = 1;
while(base <= n){
if(winner1(n-base) == "hou") return "xian";
if(base > n/4) break;//防止base*4之后溢出成复数;
base = base*4;
}

return "hou";
}

};
int main() {
//
Solution a;
int N = 20;
for(int i = 1;i<=N;i++){
cout << i <<" "<< a.winner1(i) << endl;
}
return 0;
}
 

找出规律;5个为一组,规律是后先后先先。

posted @ 2022-05-06 11:29  coyote25  阅读(28)  评论(0编辑  收藏  举报