結果

問題 No.782 マイナス進数
ユーザー htensaihtensai
提出日時 2019-12-25 13:54:28
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,017 bytes
コンパイル時間 2,680 ms
コンパイル使用メモリ 75,424 KB
実行使用メモリ 62,220 KB
最終ジャッジ日時 2023-10-25 04:42:35
合計ジャッジ時間 15,016 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
57,612 KB
testcase_01 AC 128 ms
57,444 KB
testcase_02 AC 279 ms
61,660 KB
testcase_03 AC 282 ms
61,936 KB
testcase_04 AC 282 ms
61,948 KB
testcase_05 AC 274 ms
61,656 KB
testcase_06 AC 281 ms
61,640 KB
testcase_07 AC 283 ms
61,760 KB
testcase_08 AC 285 ms
61,884 KB
testcase_09 AC 269 ms
61,604 KB
testcase_10 AC 276 ms
61,704 KB
testcase_11 AC 307 ms
61,812 KB
testcase_12 AC 300 ms
61,716 KB
testcase_13 AC 313 ms
62,220 KB
testcase_14 AC 300 ms
61,556 KB
testcase_15 AC 303 ms
61,796 KB
testcase_16 AC 303 ms
61,772 KB
testcase_17 AC 313 ms
61,416 KB
testcase_18 AC 296 ms
61,024 KB
testcase_19 AC 300 ms
61,580 KB
testcase_20 AC 304 ms
61,728 KB
testcase_21 AC 305 ms
61,064 KB
testcase_22 AC 305 ms
61,708 KB
testcase_23 AC 287 ms
60,884 KB
testcase_24 AC 329 ms
62,076 KB
testcase_25 AC 297 ms
61,696 KB
testcase_26 AC 295 ms
62,204 KB
testcase_27 AC 298 ms
61,696 KB
testcase_28 AC 300 ms
61,680 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.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        int b = - sc.nextInt();
        StringBuilder ans = new StringBuilder();
        for (int i = 0; i < t; i++) {
            boolean isPlus = true;
            int x = sc.nextInt();
            StringBuilder sb = new StringBuilder();
           while (x > 0) {
                if (isPlus) {
                    sb.append(x % b);
                    x /= b;
                    isPlus = false;
                } else {
                    if (x % b == 0) {
                        sb.append(0);
                        x /= b;
                    } else {
                        sb.append(b - x % b);
                        x /= b;
                        x++;
                    }
                    isPlus = true;
                }
            }
            ans.append(sb.reverse()).append("\n");
        }
        System.out.print(ans);
    }
}
0