結果
問題 | No.782 マイナス進数 |
ユーザー | tenten |
提出日時 | 2022-10-20 15:28:49 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 167 ms / 2,000 ms |
コード長 | 1,727 bytes |
コンパイル時間 | 1,973 ms |
コンパイル使用メモリ | 74,704 KB |
実行使用メモリ | 56,728 KB |
最終ジャッジ日時 | 2023-09-12 20:37:36 |
合計ジャッジ時間 | 7,860 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 41 ms
49,212 KB |
testcase_01 | AC | 42 ms
49,296 KB |
testcase_02 | AC | 133 ms
52,652 KB |
testcase_03 | AC | 141 ms
54,852 KB |
testcase_04 | AC | 138 ms
52,708 KB |
testcase_05 | AC | 137 ms
54,832 KB |
testcase_06 | AC | 135 ms
54,848 KB |
testcase_07 | AC | 142 ms
54,928 KB |
testcase_08 | AC | 139 ms
52,748 KB |
testcase_09 | AC | 135 ms
54,740 KB |
testcase_10 | AC | 135 ms
54,460 KB |
testcase_11 | AC | 144 ms
54,900 KB |
testcase_12 | AC | 145 ms
55,036 KB |
testcase_13 | AC | 167 ms
56,728 KB |
testcase_14 | AC | 146 ms
55,048 KB |
testcase_15 | AC | 146 ms
55,268 KB |
testcase_16 | AC | 145 ms
55,328 KB |
testcase_17 | AC | 152 ms
54,684 KB |
testcase_18 | AC | 133 ms
55,016 KB |
testcase_19 | AC | 154 ms
55,128 KB |
testcase_20 | AC | 134 ms
54,684 KB |
testcase_21 | AC | 151 ms
55,372 KB |
testcase_22 | AC | 147 ms
54,836 KB |
testcase_23 | AC | 143 ms
54,976 KB |
testcase_24 | AC | 163 ms
55,776 KB |
testcase_25 | AC | 144 ms
55,044 KB |
testcase_26 | AC | 149 ms
55,020 KB |
testcase_27 | AC | 146 ms
54,732 KB |
testcase_28 | AC | 145 ms
55,008 KB |
testcase_29 | AC | 43 ms
49,128 KB |
testcase_30 | AC | 43 ms
47,060 KB |
testcase_31 | AC | 44 ms
49,380 KB |
testcase_32 | AC | 47 ms
49,228 KB |
testcase_33 | AC | 42 ms
49,260 KB |
testcase_34 | AC | 44 ms
47,864 KB |
testcase_35 | AC | 43 ms
49,132 KB |
testcase_36 | AC | 43 ms
49,316 KB |
testcase_37 | AC | 43 ms
49,260 KB |
ソースコード
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); int base = -sc.nextInt(); StringBuilder sb = new StringBuilder(); while (n-- > 0) { int x = sc.nextInt(); if (x == 0) { sb.append("0\n"); continue; } boolean isPlus = true; StringBuilder tmp = new StringBuilder(); while (x > 0) { if (isPlus) { tmp.append(x % base); } else { tmp.append((base - (x % base)) % base); if (x % base != 0) { x += base; } } x /= base; isPlus ^= true; } sb.append(tmp.reverse()).append("\n"); } System.out.print(sb); } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public String next() throws Exception { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }