結果

問題 No.2 素因数ゲーム
ユーザー ytft
提出日時 2021-03-02 08:18:11
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,089 bytes
コンパイル時間 1,897 ms
コンパイル使用メモリ 176,248 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-10-03 01:34:14
合計ジャッジ時間 2,555 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 2 WA * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;


vector<int> natural_factorization(int n){
    int temp=2;
    vector<int> ret={};
    while(n>pow(temp,2)){
        if(n%temp==0){
            ret.push_back(temp);
            n=n/temp;
        }else{
            temp++;
        }
    }
    ret.push_back(n);
    return ret;
}

template<typename type>
tuple<vector<type>,vector<int>> vector_runlength(vector<type> v){
    vector<type> element={};
    vector<int> number={};
    int consecutive=1;
    int n=v.size();
    for(int i=1;i<n;i++){
        if(v[i]==v[i-1]){
            consecutive++;
        }else{
            element.push_back(v[i-1]);
            number.push_back(consecutive);
            consecutive=1;
        }
    }
    element.push_back(v[n-1]);
    number.push_back(consecutive);
    return forward_as_tuple(element,number);
}

int main(){
    int n;
    cin>>n;
    vector<int> a=natural_factorization(n);
    vector<int> c;
    tie(ignore,c)=vector_runlength(a);
    int p=0;
    for(int i=0;i<c.size();i++){
        p=p^c[i];
    }
    cout<<(p==0?"Alice":"Bob");
}
0