結果

問題 No.782 マイナス進数
ユーザー tentententen
提出日時 2023-01-10 09:52:57
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 2,097 bytes
コンパイル時間 2,458 ms
コンパイル使用メモリ 86,896 KB
実行使用メモリ 55,748 KB
最終ジャッジ日時 2023-08-23 09:05:59
合計ジャッジ時間 9,101 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
49,324 KB
testcase_01 AC 42 ms
49,548 KB
testcase_02 AC 134 ms
55,132 KB
testcase_03 AC 135 ms
55,004 KB
testcase_04 AC 137 ms
55,092 KB
testcase_05 AC 135 ms
55,128 KB
testcase_06 AC 132 ms
54,896 KB
testcase_07 AC 142 ms
54,772 KB
testcase_08 AC 138 ms
55,172 KB
testcase_09 AC 130 ms
54,780 KB
testcase_10 AC 133 ms
55,060 KB
testcase_11 AC 145 ms
55,220 KB
testcase_12 AC 144 ms
55,436 KB
testcase_13 AC 161 ms
55,164 KB
testcase_14 AC 144 ms
55,288 KB
testcase_15 AC 135 ms
55,056 KB
testcase_16 AC 145 ms
55,140 KB
testcase_17 AC 157 ms
55,748 KB
testcase_18 AC 144 ms
55,176 KB
testcase_19 AC 144 ms
54,944 KB
testcase_20 AC 140 ms
55,012 KB
testcase_21 AC 152 ms
54,944 KB
testcase_22 AC 135 ms
55,396 KB
testcase_23 AC 145 ms
54,768 KB
testcase_24 AC 165 ms
55,272 KB
testcase_25 AC 138 ms
55,076 KB
testcase_26 AC 149 ms
54,832 KB
testcase_27 AC 137 ms
55,392 KB
testcase_28 AC 141 ms
55,020 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 -
権限があれば一括ダウンロードができます

ソースコード

diff #

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() * (-1);
        StringBuilder sb = new StringBuilder();
        while (t-- > 0) {
            int n = sc.nextInt();
            StringBuilder tmp = new StringBuilder();
            for (int i = 0; n > 0; i++) {
                int mod = n % b;
                if (i % 2 == 1) {
                    if (mod > 0) {
                        n += b;
                    }
                    tmp.append((b - mod) % b);
                } else {
                    tmp.append(mod);
                }
                n /= b;
            }
            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();
    }
    
}
0