結果

問題 No.2 素因数ゲーム
コンテスト
ユーザー ree-rishun
提出日時 2020-05-08 03:08:53
言語 C(gnu17)
(gcc 15.2.0)
コンパイル:
gcc-15 -O2 -std=gnu17 -Wno-error=implicit-function-declaration -Wno-error=implicit-int -Wno-error=incompatible-pointer-types -Wno-error=int-conversion -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
WA  
実行時間 -
コード長 573 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 262 ms
コンパイル使用メモリ 39,292 KB
最終ジャッジ日時 2026-02-22 05:38:13
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 21 WA * 10
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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