結果

問題 No.2 素因数ゲーム
ユーザー moyashi_senpaimoyashi_senpai
提出日時 2016-08-18 21:35:44
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 1,118 ms / 5,000 ms
コード長 1,065 bytes
コンパイル時間 914 ms
コンパイル使用メモリ 74,452 KB
実行使用メモリ 198,724 KB
最終ジャッジ日時 2023-08-27 04:34:23
合計ジャッジ時間 18,192 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 115 ms
28,052 KB
testcase_07 AC 129 ms
32,076 KB
testcase_08 AC 115 ms
30,024 KB
testcase_09 AC 1,118 ms
198,724 KB
testcase_10 AC 948 ms
171,316 KB
testcase_11 AC 434 ms
83,244 KB
testcase_12 AC 428 ms
83,240 KB
testcase_13 AC 896 ms
163,216 KB
testcase_14 AC 38 ms
17,736 KB
testcase_15 AC 242 ms
50,540 KB
testcase_16 AC 627 ms
118,100 KB
testcase_17 AC 953 ms
173,532 KB
testcase_18 AC 1,027 ms
187,748 KB
testcase_19 AC 587 ms
109,876 KB
testcase_20 AC 780 ms
144,860 KB
testcase_21 AC 1,084 ms
193,988 KB
testcase_22 AC 983 ms
179,808 KB
testcase_23 AC 437 ms
85,292 KB
testcase_24 AC 1,105 ms
187,776 KB
testcase_25 AC 798 ms
140,664 KB
testcase_26 AC 561 ms
99,740 KB
testcase_27 AC 284 ms
54,656 KB
testcase_28 AC 599 ms
113,996 KB
testcase_29 AC 482 ms
93,764 KB
testcase_30 AC 449 ms
87,388 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#define REP(i,n) for(int i = 0; n > i; i++)

using namespace std;
typedef vector<int> Ivec;
typedef pair<int, int> pii;
int arr[50000000];

void Eratosthenes(int N) {
	for (int i = 0; i < N; i++) {
		arr[i] = 1;
	}
	for (int i = 2; i < sqrt(N); i++) {
		if (arr[i]) {
			for (int j = 0; i * (j + 2) < N; j++) {
				arr[i *(j + 2)] = 0;
			}
		}
	}
	int cou = 0;
	for (int i = 2; N >= i; i++) {
		if (arr[i]) {
			arr[cou] = i;
			cou++;
		}
	}
}
int main() {
	int n;
	int ans = 0,count = 0;
	scanf("%d", &n);
	Eratosthenes(n / 2 + 1);
	int cur = 0;
	while(n != 1) {
		if (arr[cur] <= 1) {
			count = 1;
			break;
		}
		else if (!(n%arr[cur])) {
			count++;
			n /= arr[cur];
		}
		else {
			ans = ans^count;
			count = 0;
			cur++;
		}
	}
	ans = ans^count;
	printf("%s\n", ans ? "Alice" : "Bob ");
	return 0;
}
0