結果

問題 No.2 素因数ゲーム
ユーザー kazukazu
提出日時 2019-03-18 16:51:42
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 524 bytes
コンパイル時間 163 ms
コンパイル使用メモリ 11,292 KB
実行使用メモリ 15,344 KB
最終ジャッジ日時 2023-09-25 14:27:50
合計ジャッジ時間 4,503 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
15,164 KB
testcase_01 AC 81 ms
15,192 KB
testcase_02 AC 81 ms
15,252 KB
testcase_03 AC 83 ms
15,128 KB
testcase_04 AC 82 ms
15,176 KB
testcase_05 AC 82 ms
15,260 KB
testcase_06 AC 81 ms
15,080 KB
testcase_07 WA -
testcase_08 AC 84 ms
15,232 KB
testcase_09 AC 82 ms
15,344 KB
testcase_10 AC 82 ms
15,032 KB
testcase_11 WA -
testcase_12 AC 80 ms
15,084 KB
testcase_13 WA -
testcase_14 AC 80 ms
15,196 KB
testcase_15 AC 82 ms
15,276 KB
testcase_16 AC 82 ms
15,136 KB
testcase_17 AC 83 ms
15,140 KB
testcase_18 AC 82 ms
15,148 KB
testcase_19 AC 81 ms
15,140 KB
testcase_20 AC 84 ms
15,144 KB
testcase_21 AC 82 ms
15,176 KB
testcase_22 WA -
testcase_23 AC 81 ms
15,132 KB
testcase_24 AC 83 ms
15,280 KB
testcase_25 AC 82 ms
15,344 KB
testcase_26 AC 82 ms
15,156 KB
testcase_27 AC 82 ms
15,280 KB
testcase_28 AC 83 ms
15,092 KB
testcase_29 AC 83 ms
15,316 KB
testcase_30 AC 80 ms
15,200 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def func(n)
	s = Math.sqrt(n).to_i
	r = 0
	result = []
	nflag = false
	ncount = 0

	(2..s).each do |i|
		if ((n % i) == 0)
			r = 0
			while(n % i == 0)
				r += 1
				n = n / i
			end
			result.push(r)
			if r > 1
				nflag = true
				ncount = 1 - ncount
			end
		end
	end

	if (n > s)
		result.push(1)
	end

	result.delete(0)


	if nflag
		if ncount == 1
			print "Alice"
		else
			print "Bob"
		end
	else
		if result.size % 2 == 1
			print "Alice"
		else
			print "Bob"
		end
	end
	print "\n"
end

func(gets.chomp.to_i)
0