結果

問題 No.782 マイナス進数
ユーザー tentententen
提出日時 2022-10-20 15:27:16
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,627 bytes
コンパイル時間 2,305 ms
コンパイル使用メモリ 74,456 KB
実行使用メモリ 56,072 KB
最終ジャッジ日時 2023-09-12 20:36:45
合計ジャッジ時間 8,463 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
49,240 KB
testcase_01 AC 43 ms
49,428 KB
testcase_02 AC 134 ms
54,916 KB
testcase_03 AC 133 ms
54,700 KB
testcase_04 AC 135 ms
55,132 KB
testcase_05 AC 135 ms
54,848 KB
testcase_06 AC 135 ms
55,008 KB
testcase_07 AC 141 ms
54,804 KB
testcase_08 AC 127 ms
55,084 KB
testcase_09 AC 132 ms
54,344 KB
testcase_10 AC 129 ms
54,700 KB
testcase_11 AC 141 ms
54,884 KB
testcase_12 AC 149 ms
54,852 KB
testcase_13 AC 170 ms
55,112 KB
testcase_14 AC 149 ms
54,964 KB
testcase_15 AC 149 ms
54,936 KB
testcase_16 AC 139 ms
54,816 KB
testcase_17 AC 159 ms
55,188 KB
testcase_18 AC 137 ms
54,768 KB
testcase_19 AC 153 ms
54,772 KB
testcase_20 AC 148 ms
54,804 KB
testcase_21 AC 156 ms
55,316 KB
testcase_22 AC 144 ms
55,108 KB
testcase_23 AC 145 ms
54,660 KB
testcase_24 AC 168 ms
56,072 KB
testcase_25 AC 146 ms
54,920 KB
testcase_26 AC 156 ms
55,096 KB
testcase_27 AC 137 ms
54,940 KB
testcase_28 AC 142 ms
55,016 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 n = sc.nextInt();
        int base = -sc.nextInt();
        StringBuilder sb = new StringBuilder();
        while (n-- > 0) {
            int x = sc.nextInt();
            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();
    }
    
}
0