結果
| 問題 | No.2 素因数ゲーム |
| コンテスト | |
| ユーザー |
ytft
|
| 提出日時 | 2021-03-02 08:21:12 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 1,090 bytes |
| コンパイル時間 | 1,607 ms |
| コンパイル使用メモリ | 175,004 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-03 01:34:19 |
| 合計ジャッジ時間 | 2,421 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 31 |
ソースコード
#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?"Bob":"Alice");
}
ytft