結果

問題 No.816 Beautiful tuples
ユーザー 👑 tatt61880tatt61880
提出日時 2021-08-11 13:04:49
言語 Kuin
(KuinC++ v.2021.9.17)
結果
AC  
実行時間 2 ms / 1,500 ms
コード長 513 bytes
コンパイル時間 2,520 ms
コンパイル使用メモリ 145,532 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-25 04:06:11
合計ジャッジ時間 3,864 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 1 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

func main()
	var a: int :: cui@inputInt()
	var b: int :: cui@inputInt()
	var ab: int :: a + b
	var c: int :: 1
	var ans: int :: -1
	while(c * c <= ab)
		if(ab % c = 0)
			if(f(a, b, c))
				do ans :: ans = -1 ?(c, lib@min(ans, c))
			end if
			var d: int :: ab / c
			if(f(a, b, d))
				do ans :: ans = -1 ?(d, lib@min(ans, d))
			end if
		end if
		do c :+ 1
	end while
	do cui@print("\{ans}\n")
	
	func f(a: int, b: int, c: int): bool
		ret a <> c & b <> c & (c + a) % b = 0 & (b + c) % a = 0
	end func
end func
0