結果

問題 No.1252 数字根D
ユーザー 👑 tatt61880tatt61880
提出日時 2021-02-15 10:34:23
言語 Kuin
(KuinC++ v.2021.9.17)
結果
AC  
実行時間 8 ms / 2,000 ms
コード長 763 bytes
コンパイル時間 1,872 ms
コンパイル使用メモリ 145,308 KB
実行使用メモリ 4,352 KB
最終ジャッジ日時 2023-10-14 17:09:25
合計ジャッジ時間 2,653 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

func main()
	var t: int :: cui@inputInt()
	for(1, t)
		var d: int :: cui@inputInt()
		var a: int :: cui@inputInt()
		var b: int :: cui@inputInt()
		var ans: int :: 0
		if(a = b)
			do ans :: f(a, d)
		else
			do ans :+ (b - a + 1) / (d - 1) * d * (d - 1) / 2
			var s: int :: f(a, d)
			var e: int :: f(b, d)
			if((e - s + 1) % (d - 1) <> 0)
				if(s = e)
					do ans :+ s
				elif(s < e)
					do ans :+ sig(s, e)
				else
					do ans :+ sig(s, d - 1) + sig(1, e)
				end if
				
				func sig(s: int, e: int): int
					ret(e * e + e - (s - 1) * (s - 1) - (s - 1)) / 2
				end func
			end if
		end if
		if(a = 0)
			do ans :- d - 1
		end if
		do cui@print("\{ans}\n")
		
		func f(a: int, d: int): int
			ret 1 + (a + d - 2) % (d - 1)
		end func
	end for
end func
0