結果

問題 No.2385 Parse Integer with Radix
ユーザー 👑 tatt61880tatt61880
提出日時 2023-07-23 11:13:34
言語 Kuin
(KuinC++ v.2021.9.17)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 567 bytes
コンパイル時間 4,987 ms
コンパイル使用メモリ 144,392 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-24 17:47:20
合計ジャッジ時間 5,878 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 1 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 1 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 1 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

func main()
	var q: int :: cui@inputInt()
	for(1, q)
		var s: []char :: cui@input()
		var base: int :: 10
		var start: int :: 0
		if(^s > 2)
			switch(s[1])
			case 'b'
				do start :: 2
				do base :: 2
			case 'o'
				do start :: 2
				do base :: 8
			case 'x'
				do start :: 2
				do base :: 16
			end switch
		end if
		var ans: int :: 0
		for i(start, ^s - 1)
			do ans :* base
			if(base <> 16 | s[i] <= '9')
				do ans :+ s[i] $ int - '0' $ int
			else
				do ans :+ s[i] $ int - 'a' $ int + 10
			end if
		end for
		do cui@print("\{ans}\n")
	end for
end func
0