結果

問題 No.816 Beautiful tuples
ユーザー yosuteconyosutecon
提出日時 2019-05-17 15:16:40
言語 Julia
(1.10.2)
結果
AC  
実行時間 358 ms / 1,500 ms
コード長 439 bytes
コンパイル時間 284 ms
コンパイル使用メモリ 7,072 KB
実行使用メモリ 247,876 KB
最終ジャッジ日時 2024-04-09 14:15:37
合計ジャッジ時間 6,332 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 358 ms
246,008 KB
testcase_01 AC 323 ms
245,728 KB
testcase_02 AC 327 ms
244,864 KB
testcase_03 AC 324 ms
245,700 KB
testcase_04 AC 322 ms
246,540 KB
testcase_05 AC 327 ms
245,324 KB
testcase_06 AC 322 ms
245,868 KB
testcase_07 AC 320 ms
245,668 KB
testcase_08 AC 322 ms
245,564 KB
testcase_09 AC 323 ms
246,292 KB
testcase_10 AC 323 ms
246,232 KB
testcase_11 AC 317 ms
245,980 KB
testcase_12 AC 321 ms
247,876 KB
testcase_13 AC 320 ms
246,388 KB
testcase_14 AC 324 ms
245,184 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1})=map(parseInt,x)

function main()
	a,b = readline() |> split |> parseMap
	c = Int[]
	r = 1
	while r <= sqrt(a+b)
		if (a+b)%r == 0
			push!(c,r)
			push!(c,div(a+b,r))
		end
		r += 1
	end
	c = sort(c)
	f = 0
	for i in 1:length(c)
		if (a+c[i])%b==0 && (b+c[i])%a==0 && a!=c[i] && b!=c[i]
			println(c[i])
			f = 1
			break
		end
	end
	if f == 0
		println(-1)
	end
end
main()
0