D. 1-2-K Game 博弈

  地址

题意:有一个东西放在n这个位置  每次可以选择向左移动1 2 或者k 步  不能小于0  不能移动则输

枚举一下k  然后画一下必胜点必败点就可以 发现规律

#include<bits/stdc++.h>
using namespace std;
//input by bxd
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define repp(i,a,b) for(int i=(a);i>=(b);--i)
#define RI(n) scanf("%d",&(n))
#define RII(n,m) scanf("%d%d",&n,&m)
#define RIII(n,m,k) scanf("%d%d%d",&n,&m,&k)
#define RS(s) scanf("%s",s)
#define ll long long
#define see(x) (cerr<<(#x)<<'='<<(x)<<endl)
#define pb push_back
#define inf 0x3f3f3f3f
#define CLR(A,v)  memset(A,v,sizeof A)
#define lson l,m,pos<<1
#define rson m+1,r,pos<<1|1
typedef pair<int,int>pii;
//////////////////////////////////
const int N=400;
int n,k;
void sol()
{
    cin>>n>>k;
    if(k%3){if(n%3) puts("Alice");else  puts("Bob");   }
    else {int s=n%(k+1); if(s%3||s==k)puts("Alice");else  puts("Bob");   }
}

int main()
{
    int cas;RI(cas);
    while(cas--)sol();
    return 0;
}
View Code
原文地址:https://www.cnblogs.com/bxd123/p/11189858.html