結果

問題 No.816 Beautiful tuples
ユーザー 👑 tatt61880tatt61880
提出日時 2020-05-09 00:00:28
言語 Kuin
(KuinC++ v.2021.9.17)
結果
AC  
実行時間 2 ms / 1,500 ms
コード長 648 bytes
コンパイル時間 2,695 ms
コンパイル使用メモリ 147,700 KB
実行使用メモリ 4,376 KB
最終ジャッジ日時 2023-10-14 16:51:58
合計ジャッジ時間 3,490 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,372 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,372 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,372 KB
testcase_08 AC 2 ms
4,372 KB
testcase_09 AC 2 ms
4,372 KB
testcase_10 AC 2 ms
4,372 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,372 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,376 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 loop(true)
		if(c * c > ab)
			break loop
		end if
		if(ab % c = 0)
			var d: int :: ab / c
			if(f(a, b, c))
				if(ans = -1)
					do ans :: c
				else
					do ans :: [ans, c].min()
				end if
			end if
			if(f(a, b, d))
				if(ans = -1)
					do ans :: d
				else
					do ans :: [ans, d].min()
				end if
			end if
		end if
		do c :+ 1
	end while
	do cui@print("\{ans}\n")
	
	func f(a: int, b: int, c: int): bool
		if(a = c | b = c)
			ret false
		end if
		ret(c + a)%b = 0 & (b + c)%a = 0
	end func
end func
0