結果
問題 | No.2385 Parse Integer with Radix |
ユーザー | 👑 Mizar |
提出日時 | 2023-06-26 22:31:59 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 149 ms / 2,000 ms |
コード長 | 593 bytes |
コンパイル時間 | 2,295 ms |
コンパイル使用メモリ | 74,564 KB |
実行使用メモリ | 54,388 KB |
最終ジャッジ日時 | 2024-07-03 17:34:55 |
合計ジャッジ時間 | 5,355 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 137 ms
54,152 KB |
testcase_01 | AC | 149 ms
54,388 KB |
testcase_02 | AC | 145 ms
53,776 KB |
testcase_03 | AC | 146 ms
54,248 KB |
testcase_04 | AC | 145 ms
53,748 KB |
testcase_05 | AC | 139 ms
53,828 KB |
testcase_06 | AC | 144 ms
53,516 KB |
testcase_07 | AC | 135 ms
54,004 KB |
testcase_08 | AC | 138 ms
53,828 KB |
testcase_09 | AC | 141 ms
53,576 KB |
testcase_10 | AC | 146 ms
53,620 KB |
testcase_11 | AC | 147 ms
54,124 KB |
ソースコード
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int q = sc.nextInt(); for (int i = 0; i < q; i++) { String s = sc.next(); long n = 0; switch(s.substring(0, Math.min(2, s.length()))) { case "0b": n = Long.parseLong(s.substring(2), 2); break; case "0o": n = Long.parseLong(s.substring(2), 8); break; case "0x": n = Long.parseLong(s.substring(2), 16); break; default: n = Long.parseLong(s, 10); } System.out.println(n); } } }