結果

問題 No.2 素因数ゲーム
ユーザー iwashi31iwashi31
提出日時 2014-11-20 21:54:34
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,171 bytes
コンパイル時間 923 ms
コンパイル使用メモリ 77,768 KB
実行使用メモリ 5,332 KB
最終ジャッジ日時 2023-08-30 21:55:17
合計ジャッジ時間 2,422 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <deque>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>

using namespace std;

long int N;
vector<int> prime;

bool check(vector<int> vec) {
	int i, j;
	int size = vec.size();
	bool flag = false;
	vector<int> c_vec;

	for (i = 0; i < size; i++) {
		if (vec[i] > 0) c_vec.push_back(vec[i]);
	}
	sort(c_vec.begin(), c_vec.end());
	
	c_vec.swap(vec);
	size = vec.size();

	if (size == 0) return false;
	if (size == 1) return true;
	
	for (i = 0; i < size && !flag; i++) {
		c_vec.clear();
		for (j = 0; j < size; j++) {
			c_vec.push_back(vec[j]);
		}
		for (j = 1; j <= vec[i]; j++) {
			c_vec[i]--;
			if (!check(c_vec)) {
				flag = true;
				break;
			}
		}
	}

	return flag;
}

int main() {
	long int i;

	cin >> N;

	for (i = 2; i < 10000 && N > 1; i++) {
		int count = 0;
		while (N % i == 0) {
			count++;
			N /= i;
		}
		prime.push_back(count);
	}

	bool flag = check(prime);

	if (flag) cout << "Alice" << endl;
	else cout << "Bob" << endl;

	return 0;
}
0