結果

問題 No.2125 Inverse Sum
ユーザー 👑 tatt61880tatt61880
提出日時 2023-03-19 22:50:20
言語 Kuin
(KuinC++ v.2021.9.17)
結果
WA  
実行時間 -
コード長 932 bytes
コンパイル時間 5,553 ms
コンパイル使用メモリ 148,864 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-18 17:55:01
合計ジャッジ時間 4,825 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 2 ms
4,348 KB
testcase_07 WA -
testcase_08 WA -
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 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 2 ms
4,348 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 2 ms
4,348 KB
testcase_22 WA -
testcase_23 AC 2 ms
4,348 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 1 ms
4,348 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 2 ms
4,348 KB
testcase_31 WA -
testcase_32 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

func main()
	var p: int :: cui@inputInt()
	var q: int :: cui@inputInt()
	
	if(p = q)
		do cui@print("1\n2 2\n")
		ret
	end if
	
	var gcd: int :: math@gcd(p, q)
	do p :/ gcd
	do q :/ gcd
	
	; n = a * c
	; m = b * c
	; p = a + b
	; q = a * b * c
	
	var ansNM: []NM :: #[0]NM
	
	for a(1, p - 1)
		var b: int :: p - a
		if(a * b > q)
			break a
		end if
		if(q % (a * b) = 0)
			var c: int :: q / (a * b)
			var n: int :: a * c
			var m: int :: b * c
			do ansNM :~ [(#NM).init(n, m)]
		end if
	end for
	
	do cui@print("\{^ansNM}\n")
	for i(0, ^ansNM - 1)
		var n: int :: ansNM[i].n
		var m: int :: ansNM[i].m
		do cui@print("\{n} \{m}\n")
	end for
	
	class NM()
		+var n: int
		+var m: int
		+func init(n: int, m: int): NM
			do me.n :: n
			do me.m :: m
			ret me
		end func
		
		+*func cmp(t: kuin@Class): int
			if(me.n < (t $ NM).n)
				ret -1
			elif(me.n > (t $ NM).n)
				ret 1
			end if
			ret 0
		end func
	end class
end func
0