結果
| 問題 | No.2 素因数ゲーム |
| コンテスト | |
| ユーザー |
ikashoppin
|
| 提出日時 | 2021-05-05 12:06:47 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 1,346 bytes |
| コンパイル時間 | 2,028 ms |
| コンパイル使用メモリ | 183,384 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-13 03:53:20 |
| 合計ジャッジ時間 | 2,917 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 31 |
コンパイルメッセージ
main.cpp: In lambda function:
main.cpp:47:5: warning: control reaches end of non-void function [-Wreturn-type]
47 | };
| ^
ソースコード
#include<bits/stdc++.h>
using namespace std;
using lli = long long;
#define rep(i,n) for(int i=0;i<n;i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>
ostream &operator<<(ostream &os, const vector<T> &x){
os << "{";
for(size_t i = 0; i < x.size(); i++){
if(i < x.size()-1) os << x[i] << ", ";
else os << x[i];
}
os << "}";
return os;
}
int main(void){
int n;
cin >> n;
unordered_map<int, int> m;
int k = n;
for(int i = 2; i*i <= k; i++){
while(k%i == 0){
k/=i;
m[i]++;
}
}
if(k != 1) m[k] = 1;
unordered_map<int, int> memo;
function<int(int)> g = [&](int x){
if(memo.count(x) == 1) return memo[x];
if(x == 1) return memo[x] = 0;
unordered_map<int, bool> mex;
for(auto mi : m){
int k = x;
while(k%mi.first == 0){
mex[g(k/mi.first)] = true;
k/=mi.first;
}
}
for(int i = 0; i <= x; i++){
if(!mex[i]){
return memo[x] = i;
}
}
};
if(g(n) == 0) cout << "Bob" << endl;
else cout << "Alice" << endl;
return 0;
}
ikashoppin