結果

問題 No.2 素因数ゲーム
ユーザー iwashi31iwashi31
提出日時 2014-11-20 22:23:50
言語 C++11
(gcc 11.4.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,360 bytes
コンパイル時間 817 ms
コンパイル使用メモリ 91,340 KB
実行使用メモリ 395,812 KB
最終ジャッジ日時 2023-08-30 21:55:40
合計ジャッジ時間 4,490 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 47 ms
25,292 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 3 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 3 ms
4,376 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 8 ms
5,288 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 WA -
testcase_20 AC 616 ms
283,700 KB
testcase_21 WA -
testcase_22 AC 46 ms
23,644 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 3 ms
4,380 KB
testcase_25 AC 35 ms
18,784 KB
testcase_26 AC 2 ms
4,380 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,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

using namespace std;

long int N;
vector<int> prime;
map< vector<int>, bool > wflag;

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 (wflag.find(vec) != wflag.end()) {
		return wflag[vec];
	}

	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;
			}
		}
	}

	wflag.insert( map< vector<int>, bool >::value_type(vec, flag) );

	return flag;
}

int main() {
	long int i;

	cin >> N;

	for (i = 2; i < 50000000 && 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