結果

問題 No.782 マイナス進数
ユーザー tentententen
提出日時 2022-08-12 09:50:02
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,546 bytes
コンパイル時間 2,995 ms
コンパイル使用メモリ 78,228 KB
実行使用メモリ 60,220 KB
最終ジャッジ日時 2023-10-23 19:59:37
合計ジャッジ時間 10,223 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 53 ms
53,544 KB
testcase_01 AC 53 ms
53,552 KB
testcase_02 AC 143 ms
55,436 KB
testcase_03 AC 148 ms
58,196 KB
testcase_04 AC 148 ms
58,052 KB
testcase_05 AC 145 ms
53,908 KB
testcase_06 AC 145 ms
55,860 KB
testcase_07 AC 150 ms
57,556 KB
testcase_08 AC 146 ms
57,916 KB
testcase_09 AC 145 ms
55,440 KB
testcase_10 AC 147 ms
55,688 KB
testcase_11 AC 157 ms
58,092 KB
testcase_12 AC 155 ms
58,272 KB
testcase_13 AC 176 ms
58,716 KB
testcase_14 AC 151 ms
57,940 KB
testcase_15 AC 157 ms
57,832 KB
testcase_16 AC 143 ms
58,308 KB
testcase_17 AC 169 ms
58,112 KB
testcase_18 AC 158 ms
55,860 KB
testcase_19 AC 164 ms
57,968 KB
testcase_20 AC 144 ms
57,956 KB
testcase_21 AC 166 ms
58,156 KB
testcase_22 AC 153 ms
57,924 KB
testcase_23 AC 157 ms
58,052 KB
testcase_24 AC 179 ms
60,220 KB
testcase_25 AC 156 ms
58,232 KB
testcase_26 AC 158 ms
58,072 KB
testcase_27 AC 155 ms
58,152 KB
testcase_28 AC 154 ms
57,964 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.*;

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 x = sc.nextInt();
            StringBuilder current = new StringBuilder();
            boolean isPlus = true;
            while (x > 0) {
                int mod = x % b;
                if (isPlus) {
                    current.append(mod);
                } else {
                    current.append((b - mod) % b);
                    x += (b - mod) % b;
                }
                isPlus ^= true;
                x /= b;
            }
            sb.append(current.reverse()).append("\n");
        }
        System.out.print(sb);
    }
}

class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    
    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();
    }
}
0