Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- typedef long long int ll;
- typedef unsigned long long int ull;
- typedef long double ld;
- ll mod = 1e9+7;
- const double error = 1e-7;
- const double PI = acos(-1); //const ld PI = acosl(-1)
- #define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);
- #define eq(x, y) (fabs((x)-(y))<error)
- #define bt(i) (1LL<<(i))
- #define debug(x) cerr<<#x<<" = "<<(x)<<"\n"
- #define hoise cerr<<"hoise\n"
- #define tham getchar()
- mt19937_64 rng((unsigned int) chrono::system_clock::now().time_since_epoch().count());
- inline ll MOD(ll x, ll m = mod)
- {
- ll y = x % m;
- return (y >= 0) ? y: y+m;
- }
- const int inf = 1e8+5;
- const ll infl = 1e15;
- const int nmax = 1e5+5;
- const int nmax2 = 1e7+5;
- ///====================== template =========================
- int grundystone[nmax2];
- int grundypile[nmax];
- void precal(){
- for(int i = 2; i<nmax2; i++){
- int j;
- if(i%7 == 0) j = i/7;
- else if(i % 4 == 0) j = i/4;
- else j = i/3;
- if(j < 3) grundystone[i] = 0;
- else grundystone[i] = grundystone[j]^1;
- }
- for(int i = 1; i<nmax; i++){
- if(i == 4 || i == 7) grundypile[i] = -1;
- else{
- vector<int> v;
- if(i-4>0) v.push_back(grundypile[i-4]);
- if(i-7>0) v.push_back(grundypile[i-7]);
- sort(v.begin(), v.end());
- int ret = 0;
- for(int x: v) if(ret == x) ret++;
- grundypile[i] = ret;
- }
- }
- }
- int G(int x){
- if(x < nmax2) return grundystone[x];
- if(x % 7 == 0) return G(x/7)^1;
- else if(x % 4 == 0) return G(x/4)^1;
- else return G(x/3)^1;
- }
- int main(){
- FASTIO;
- precal();
- //for(int i = 0; i<20; i++) {debug(i);debug(grundystone[i]);}
- int tc;
- cin>>tc;
- for(int cs = 1; cs<=tc; cs++){
- int n, m;
- cin>>n>>m;
- if(n == 4 || n == 7 || m == 1 || m == 2){
- cout<<"Case "<<cs<<": Alice\n";
- continue;
- }
- int x = grundypile[n] ^ G(m);
- cout<<"Case "<<cs<<": ";
- if(x == 0) cout<<"Bob\n";
- else cout<<"Alice\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement