結果

問題 No.1113 二つの整数 / Two Integers
ユーザー 小野寺健小野寺健
提出日時 2021-11-03 13:55:38
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 426 bytes
コンパイル時間 168 ms
コンパイル使用メモリ 7,680 KB
実行使用メモリ 17,664 KB
最終ジャッジ日時 2024-04-21 04:50:13
合計ジャッジ時間 3,843 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
17,664 KB
testcase_01 AC 82 ms
12,288 KB
testcase_02 AC 281 ms
12,032 KB
testcase_03 AC 247 ms
12,160 KB
testcase_04 AC 243 ms
12,288 KB
testcase_05 TLE -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:14: warning: assigned but unused variable - ex
Syntax OK

ソースコード

diff #

A, B = gets.split(" ").map{|s| s.to_i}

def gcd(x, y)
	if y == 0 then
		x
	else
		gcd(y, x%y)
	end
end

def nod(n)
	return 1 if n == 1
	res = Hash.new(0)
	ex = 0
	while n % 2 == 0 do
		res[2] += 1
		n /= 2
	end
	f = 3
	while f * f <= n
		if n % f == 0 then
			res[f] += 1
			n /= f
		else
			f += 2
		end
	end
	res[n] += 1 if n != 1
	res.values.map{|x| x+1}.inject(:*)
end

g = gcd(A, B)

puts nod(g) % 2 == 0 ? "Even" : "Odd"
0