結果
問題 | No.782 マイナス進数 |
ユーザー | tenten |
提出日時 | 2023-07-07 16:09:07 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,270 bytes |
コンパイル時間 | 3,990 ms |
コンパイル使用メモリ | 79,900 KB |
実行使用メモリ | 56,384 KB |
最終ジャッジ日時 | 2023-09-28 16:45:19 |
合計ジャッジ時間 | 10,746 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 44 ms
49,388 KB |
testcase_01 | AC | 45 ms
49,284 KB |
testcase_02 | AC | 140 ms
54,684 KB |
testcase_03 | AC | 142 ms
54,648 KB |
testcase_04 | AC | 147 ms
54,896 KB |
testcase_05 | AC | 146 ms
54,936 KB |
testcase_06 | AC | 142 ms
55,188 KB |
testcase_07 | AC | 144 ms
54,556 KB |
testcase_08 | AC | 145 ms
55,240 KB |
testcase_09 | AC | 141 ms
54,584 KB |
testcase_10 | AC | 139 ms
55,036 KB |
testcase_11 | AC | 141 ms
55,012 KB |
testcase_12 | AC | 149 ms
55,036 KB |
testcase_13 | AC | 174 ms
56,384 KB |
testcase_14 | AC | 143 ms
55,436 KB |
testcase_15 | AC | 158 ms
55,292 KB |
testcase_16 | AC | 153 ms
54,944 KB |
testcase_17 | AC | 159 ms
54,884 KB |
testcase_18 | AC | 149 ms
55,064 KB |
testcase_19 | AC | 146 ms
52,944 KB |
testcase_20 | AC | 149 ms
55,408 KB |
testcase_21 | AC | 164 ms
55,240 KB |
testcase_22 | AC | 152 ms
54,680 KB |
testcase_23 | AC | 139 ms
55,380 KB |
testcase_24 | AC | 171 ms
53,148 KB |
testcase_25 | AC | 154 ms
54,884 KB |
testcase_26 | AC | 155 ms
55,348 KB |
testcase_27 | AC | 145 ms
55,108 KB |
testcase_28 | AC | 153 ms
54,756 KB |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | WA | - |
ソースコード
import java.io.*; import java.util.*; import java.util.stream.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int t = sc.nextInt(); int b = -sc.nextInt(); StringBuilder sb = new StringBuilder(); while (t-- > 0) { int n = sc.nextInt(); StringBuilder tmp = new StringBuilder(); boolean isPlus = true; while (n > 0) { int mod = n % b; if (isPlus) { tmp.append(mod); n /= b; } else { if (mod > 0) { tmp.append(b - mod); n /= b; n++; } else { tmp.append(0); n /= b; } } isPlus ^= true; } sb.append(tmp.reverse()).append("\n"); } System.out.print(sb); } } class Utilities { static String arrayToLineString(Object[] arr) { return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n")); } static String arrayToLineString(int[] arr) { return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new)); } } 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 int[] nextIntArray() throws Exception { return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray(); } public String next() throws Exception { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }