結果

問題 No.2 素因数ゲーム
ユーザー ReERishun
提出日時 2020-05-08 03:08:53
言語 C
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 573 bytes
コンパイル時間 179 ms
コンパイル使用メモリ 29,568 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-03 09:44:26
合計ジャッジ時間 3,073 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 21 WA * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>

int main() {
	int ans = 0;
	int num = 0;
	int array[20000];

	// 入力
	scanf("%d", &num);

	// 2で割れるか
	if (!num % 2)
		ans++;
	
	// 素数探索ループ
	for (int i = 3; i < num; i += 2) {
		if (num%i == 0) {
			if (ans > 1) {
				for (int j = 0;; j++) {
					if (ans%array[j] == 0) {
						break;
					}
					else if (j == ans - 2) {
						array[ans] = i;
						ans++;
						break;
					}
				}
			}
			else {
				array[ans] = i;
				ans++;
			}
		}
	}

	// 回答出力
	if (ans % 2)
		printf("Alice");
	else
		printf("Bob");

	return 0;
}
0