結果

問題 No.103 素因数ゲーム リターンズ
ユーザー srjywrdnprktsrjywrdnprkt
提出日時 2022-12-23 03:47:04
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 947 bytes
コンパイル時間 1,191 ms
コンパイル使用メモリ 147,688 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-29 04:10:33
合計ジャッジ時間 2,247 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <queue>
#include <algorithm>
#include <numeric>
#include <deque>
#include <sstream>

using namespace std;

vector<long long> spf;
map<long long, long long> prime;

void osa_k(long long n){
    spf.resize(n+1);
    for (long long i=0; i<=n; i++) spf[i] = i;
    for (long long i=2; i*i<=n; i++){
        if (spf[i] == i){
            for (long long j=2; i*j <= n; j++){
                spf[i*j] = min(spf[i*j], i);
            }
        }
    }
}

void prime_factor(long long n){
    prime.clear();
    while(n != 1){
        prime[spf[n]]++;
        n /= spf[n];
    }
}

int main(){
    osa_k(10000);
    long long N, g=0, M;
    cin >> N;

    for (int i=0; i<N; i++){
        cin >> M;
        prime_factor(M);
        for (auto [x, y] : prime) g ^= (y % 3);
    }

    cout << (g != 0 ? "Alice" : "Bob") << endl;

    return 0;
}
0