/* -*- coding: utf-8 -*- * * 103.cc: No.103 素因数ゲーム リターンズ - yukicoder */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; /* constant */ const int MAX_N = 100; const int MAX_P = 10000; const int MAX_F = 14; // 2^14 = 16384 > 10000 const int INF = 1 << 30; /* typedef */ typedef vector vi; typedef pair pii; typedef vector vpii; typedef map mvib; /* global variables */ bool primes[MAX_P + 1]; int ms[MAX_N]; mvib dp; /* subroutines */ void gen_primes(int maxp, vi &pnums) { memset(primes, true, sizeof(primes)); primes[0] = primes[1] = false; int p; for (p = 2; p * p <= maxp; p++) if (primes[p]) { pnums.push_back(p); for (int q = p * p; q <= maxp; q += p) primes[q] = false; } for (; p <= maxp; p++) if (primes[p]) pnums.push_back(p); } bool prime_decomp(int n, vi &pnums, vpii& pds) { pds.clear(); int pn = pnums.size(); for (int i = 0; i < pn; i++) { int pi = pnums[i]; if (pi * pi > n) { if (n > 1) pds.push_back(pii(n, 1)); return true; } if (n % pi == 0) { int fi = 0; while (n % pi == 0) n /= pi, fi++; pds.push_back(pii(pi, fi)); } } return false; } bool rec(vi &fs) { mvib::iterator mit = dp.find(fs); if (mit != dp.end()) return mit->second; int fn = fs.size(); vi fs0(fs); for (int i = 0; i < fn; i++) { if (fs[i] == 0) continue; fs0[i]--; for (int d = 1, j = i - 1; d <= 2; d++, j--) { if (j >= 0) { fs0[j]++; if (! rec(fs0)) return (dp[fs] = true); fs0[j]--; } else { if (! rec(fs0)) return (dp[fs] = true); } } fs0[i]++; } return (dp[fs] = false); } /* main */ int main() { vi pnums; gen_primes(MAX_P, pnums); int n; cin >> n; for (int i = 0; i < n; i++) cin >> ms[i]; vi fs(MAX_F); for (int i = 0; i < n; i++) { vpii pds; prime_decomp(ms[i], pnums, pds); for (int j = 0; j < pds.size(); j++) fs[pds[j].second - 1]++; } while (fs.size() > 0 && fs.back() == 0) fs.pop_back(); int fn = fs.size(); //for (int i = 0; i < fn; i++) printf("%d ", fs[i]); putchar('\n'); dp[vi(fn, 0)] = false; bool ans = rec(fs); cout << (ans ? "Alice" : "Bob") << endl; return 0; }