結果
問題 | No.103 素因数ゲーム リターンズ |
ユーザー |
|
提出日時 | 2024-09-01 02:23:06 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 2,342 bytes |
コンパイル時間 | 3,572 ms |
コンパイル使用メモリ | 267,996 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-01 02:23:11 |
合計ジャッジ時間 | 4,511 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 20 |
ソースコード
#ifdef ONLINE_JUDGE#define NDEBUG#endif#if defined(__GNUC__) && !defined(__clang__)// #pragma GCC optimize("O3")// #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")#pragma GCC optimize("unroll-loops")#endif#include <bits/stdc++.h>using namespace std;#if __cplusplus >= 202002Lnamespace R = ranges;namespace V = views;#endifusing i64 = long long;using u64 = unsigned long long;using f64 = double;using uz = size_t;using u32 = uint32_t;using itn = int;template <typename T> using ve = vector<T>;template <typename T> using a2 = array<T, 2>;template <typename K, typename V> using HashMap = unordered_map<K, V>;template <typename T> using HashSet = unordered_set<T>;template <typename T, typename C = less<T>>using PQ = std::priority_queue<T, vector<T>, C>;template <typename T, typename C = greater<T>>using miPQ = std::priority_queue<T, vector<T>, C>;#define mt make_tuple#define mp make_pair#ifdef LOCAL#include "debug_template.cpp"#else#define debug(...)#define debugArr(...)#endif// constexpr array<int, 5> dirs{-1, 0, 1, 0, -1};// constexpr char nesw[4]{'N', 'E', 'S', 'W'};// constexpr int M = 1e9 + 7;void cln() { cout << '\n'; }constexpr char ln = '\n';array<int, int(1e4) + 5> dp;int g(int n, ve<a2<int>> &cnt) {if (n == 1) {return 0;}int &memo = dp[n];if (memo != -1) {return memo;}bitset<20> in(UINT_MAX);for (int i = 0; i < cnt.size(); ++i) {if (cnt[i][1] == 0) {continue;}cnt[i][1] -= 1;in.reset(g(n / cnt[i][0], cnt));cnt[i][1] += 1;if (cnt[i][1] != 1) {cnt[i][1] -= 2;in.reset(g(n / (cnt[i][0] * cnt[i][0]), cnt));cnt[i][1] += 2;}}return memo = in._Find_first();}int f(int n) {int memo = dp[n];if (memo != -1) {return memo;}const int on = n;ve<a2<int>> cnt;cnt.reserve(15);for (int i = 2; i * i <= on; ++i) {if (n % i == 0) {cnt.push_back({i, 0});do {n /= i;cnt.back()[1] += 1;} while (n % i == 0);}}if (n != 1) {cnt.push_back({n, 1});}return g(on, cnt);}int main() {#ifndef LOCALios::sync_with_stdio(0), cin.tie(0);#endif//dp.fill(-1);int n;cin >> n;int ans{};while (n--) {int m;cin >> m;ans ^= f(m);}cout << (ans ? "Alice\n" : "Bob\n");}