結果

問題 No.2 素因数ゲーム
ユーザー koba-e964koba-e964
提出日時 2015-05-02 02:28:53
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,934 bytes
コンパイル時間 869 ms
コンパイル使用メモリ 90,848 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-27 03:46:27
合計ジャッジ時間 1,994 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 1 ms
4,376 KB
testcase_29 AC 1 ms
4,376 KB
testcase_30 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>


using namespace std;
class Power {
	typedef long long i64;
public:
	/* a^b with no modulo operations */
	static long long power(long long a, long long b) {
		i64 s = 1;
		i64 c = a;
		while (b > 0) {
			if (b % 2) {
				s *= c;
			}
			c *= c;
			b /= 2;
		}
		return s;
	}
	/* return (a,b) s.t, n = a^b and b is maximal. O(64) */
	static pair<long long, int> toPower(long long n) {
		for (int i = 64; i >= 2; i--) {
			i64 app = pow(n, 1.0/i);
			for (int d = -4; d <= 4; d++) {
				i64 x = app + d;
				if (x <= 0) continue;
				if (power(x, i) == n) {
					return pair<i64, int>(x, i);
				}
			}
		}
		return pair<i64, int>(n, 1);
	}
	/* factorize n and returns prime factors and their exponents.  O(sqrt(n)) */
	static vector<pair<long long, int> > factorize(long long n) {
		vector<pair<i64, int> > res;
		i64 p = 2;
		int c = 0;
		while (n >= 1) {
			if (c == 0 && n < p * p) {
			  if(n != 1) {
			    res.push_back(pair<i64, int>(n,1));
			  }
			  break;
			}
			if (n % p != 0) {
				if (c > 0) {
					res.push_back(pair<i64, int>(p,c));
				}
				p++;
				c = 0;
				continue;
			}
			n /= p;
			c++;
		}
		return res;
	}
};

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef pair<int, int> PI;
const double EPS=1e-9;



int main(void){
  ll n;
  cin >> n;
  vector<pair<ll, int> > fac = Power::factorize(n);
  int k = 0;
  REP(i, 0, fac.size()) {
    k ^= fac[i].second;
  }
  cout << (k ? "Alice" : "Bob") << endl;
}
0