結果
| 問題 | No.2 素因数ゲーム |
| コンテスト | |
| ユーザー |
ytft
|
| 提出日時 | 2021-03-02 08:20:15 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,109 bytes |
| 記録 | |
| コンパイル時間 | 1,594 ms |
| コンパイル使用メモリ | 174,864 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-03 01:34:16 |
| 合計ジャッジ時間 | 2,468 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | WA * 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<<endl;
cout<<(p==0?"Bob":"Alice");
}
ytft