結果

問題 No.782 マイナス進数
ユーザー tentententen
提出日時 2023-04-24 15:12:11
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 2,090 bytes
コンパイル時間 2,484 ms
コンパイル使用メモリ 92,732 KB
実行使用メモリ 45,904 KB
最終ジャッジ日時 2024-04-26 04:22:45
合計ジャッジ時間 9,077 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
37,136 KB
testcase_01 AC 49 ms
37,288 KB
testcase_02 AC 131 ms
41,064 KB
testcase_03 AC 146 ms
41,412 KB
testcase_04 AC 149 ms
40,952 KB
testcase_05 AC 147 ms
41,136 KB
testcase_06 AC 141 ms
40,668 KB
testcase_07 AC 151 ms
41,408 KB
testcase_08 AC 143 ms
41,284 KB
testcase_09 AC 133 ms
41,208 KB
testcase_10 AC 143 ms
41,032 KB
testcase_11 AC 155 ms
41,652 KB
testcase_12 AC 148 ms
41,716 KB
testcase_13 AC 175 ms
45,904 KB
testcase_14 AC 145 ms
41,712 KB
testcase_15 AC 150 ms
41,768 KB
testcase_16 AC 155 ms
41,720 KB
testcase_17 AC 167 ms
42,440 KB
testcase_18 AC 153 ms
41,648 KB
testcase_19 AC 162 ms
42,468 KB
testcase_20 AC 153 ms
41,376 KB
testcase_21 AC 162 ms
41,980 KB
testcase_22 AC 151 ms
41,436 KB
testcase_23 AC 152 ms
41,616 KB
testcase_24 AC 179 ms
44,232 KB
testcase_25 AC 146 ms
41,528 KB
testcase_26 AC 155 ms
41,692 KB
testcase_27 AC 154 ms
41,744 KB
testcase_28 AC 152 ms
41,304 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 n = sc.nextInt();
        int base = -sc.nextInt();
        StringBuilder sb = new StringBuilder();
        while (n-- > 0) {
            int x = sc.nextInt();
            boolean isEven = true;
            StringBuilder tmp = new StringBuilder();
            while (x > 0) {
                if (isEven) {
                    tmp.append(x % base);
                } else {
                    tmp.append((base - x % base) % base);
                    x += (base - x % base) % base;
                }
                x /= base;
                isEven ^= 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();
    }
    
}
0