結果
| 問題 | No.2 素因数ゲーム |
| コンテスト | |
| ユーザー |
alpha_virginis
|
| 提出日時 | 2016-08-09 07:44:58 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 5,000 ms |
| コード長 | 1,368 bytes |
| コンパイル時間 | 2,482 ms |
| コンパイル使用メモリ | 184,084 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-26 12:37:31 |
| 合計ジャッジ時間 | 3,727 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 31 |
ソースコード
#include <bits/stdc++.h>
template<typename T> T in() { abort(); return T(); }
template<> std::string in() { std::string str; std::cin >> str; return str; }
template<> int in() { int x; scanf("%d", &x); return x; }
template<typename T> void out(T x) { abort(); }
template<> void out(const char* x) { printf("%s\n", x); }
template<> void out(std::string x) { std::cout << x << std::endl; }
template<> void out(int x) { printf("%d\n", x); }
template<> void out(long x) { printf("%ld\n", x); }
std::map<int, std::vector<int>> map;
std::map<int, bool> flags;
void pf(int n) {
if( map.count(n) != 0 ) return;
std::vector<int> next;
std::vector<int> factors;
{
int t = n;
for(int i = 2; i * i <= t; ++i) {
if( t % i != 0 ) continue;
factors.push_back(i);
while( t % i == 0 ) t /= i;
}
if( t != 1 ) factors.push_back(t);
}
for(int x : factors) {
int t = n;
while( t % x == 0 ) {
next.push_back(t / x);
t /= x;
}
}
map[n] = next;
for(int x : next) {
pf(x);
}
}
int main() {
int n = in<int>();
pf(n);
flags[1] = false;
for(auto &nxs : map) {
int n = nxs.first;
std::vector<int>& xs = nxs.second;
if( n == 1 ) continue;
bool b = true;
for(int j : xs) {
b = b && flags[j];
}
flags[n] = not b;
}
out(flags[n] ? "Alice" : "Bob");
return 0;
}
alpha_virginis