結果

問題 No.2 素因数ゲーム
ユーザー n0ma_run0ma_ru
提出日時 2024-03-16 18:59:47
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 5,000 ms
コード長 1,390 bytes
コンパイル時間 2,439 ms
コンパイル使用メモリ 211,996 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-03-16 18:59:51
合計ジャッジ時間 3,782 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 3 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 2 ms
6,676 KB
testcase_09 AC 2 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 2 ms
6,676 KB
testcase_12 AC 2 ms
6,676 KB
testcase_13 AC 2 ms
6,676 KB
testcase_14 AC 2 ms
6,676 KB
testcase_15 AC 2 ms
6,676 KB
testcase_16 AC 2 ms
6,676 KB
testcase_17 AC 2 ms
6,676 KB
testcase_18 AC 2 ms
6,676 KB
testcase_19 AC 2 ms
6,676 KB
testcase_20 AC 2 ms
6,676 KB
testcase_21 AC 2 ms
6,676 KB
testcase_22 AC 2 ms
6,676 KB
testcase_23 AC 2 ms
6,676 KB
testcase_24 AC 1 ms
6,676 KB
testcase_25 AC 2 ms
6,676 KB
testcase_26 AC 2 ms
6,676 KB
testcase_27 AC 2 ms
6,676 KB
testcase_28 AC 2 ms
6,676 KB
testcase_29 AC 2 ms
6,676 KB
testcase_30 AC 2 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define ALL(v) v.begin(),v.end()
#define dbg(x) cerr << #x << ": " << (x) << endl;
template<class F, class S>
ostream& operator<<(ostream& os, pair<F,S>& p) {
    os << '(' << p.first << ',' << p.second << ')';
    return os;
}
template<class Iter>
void print(Iter beg, Iter end) {
    for (Iter itr = beg; itr != end; ++itr) {
        cerr << *itr << ' ';
    }
    cerr << '\n';
}
int MAX = 0;
int N;
vector<int> prime;
map<int, int> note;

int grundy(int n) {
    if (note.count(n)) return note[n];

    bool exist0 = false;
    for (int p : prime) {
        int x = p;
        while (n % x == 0) {
            if (grundy(n / x) == 0) {
                exist0 = true;
                break;
            }
            x *= p;
        }
    }
    return note[n] = exist0;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> N;

    int tmp = N;
    for (int i = 2; i*i <= tmp; ++i) {
        if (tmp % i == 0) {
            prime.push_back(i);
            while (tmp % i == 0) {
                ++MAX;
                tmp /= i;
            }
        }
    }
    if (tmp > 1) {
        prime.push_back(tmp);
        ++MAX;
    }
    // print(ALL(prime));
    // dbg(MAX)

    note[1] = 0;
    int g = grundy(N);
    // print(ALL(note));
    cout << (g==0 ? "Bob" : "Alice") << '\n';
}
0