結果

問題 No.2 素因数ゲーム
ユーザー myanta
提出日時 2017-04-03 23:39:43
言語 C
(gcc 13.3.0)
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 633 bytes
コンパイル時間 489 ms
コンパイル使用メモリ 29,824 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-26 12:56:31
合計ジャッジ時間 1,636 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>


int factoring2(int fact[], int factn[], int x)
{
	int i, j, n=0;

	if(x<2) return 0;

	if((x&1)==0)
	{
		x>>=1;
		for(j=1;(x&1)==0;j++) x>>=1;

		fact[n]=2;
		factn[n]=j;
		n++;
	}

	for(i=3;i*i<=x;i+=2)
	{
		if((x%i)==0)
		{
			x/=i;
			for(j=1;(x%i)==0;j++) x/=i;

			fact[n]=i;
			factn[n]=j;
			n++;
		}
	}
	if(x>1)
	{
		fact[n]=x;
		factn[n]=1;
		n++;
	}

	return n;
}


int main(void)
{
	int fact[30], factn[30];
	int N, i, n, chk;

	while(scanf("%d", &N)==1)
	{
		n=factoring2(fact, factn, N);
		chk=0;
		for(i=0;i<n;i++) chk^=factn[i];
		if(chk) printf("Alice\n");
		else printf("Bob\n");
	}
	return 0;
}
0