結果

問題 No.782 マイナス進数
ユーザー tentententen
提出日時 2020-09-01 09:08:50
言語 Java19
(openjdk 21)
結果
AC  
実行時間 313 ms / 2,000 ms
コード長 771 bytes
コンパイル時間 2,404 ms
コンパイル使用メモリ 71,588 KB
実行使用メモリ 62,188 KB
最終ジャッジ日時 2023-08-11 05:29:40
合計ジャッジ時間 15,323 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
55,580 KB
testcase_01 AC 128 ms
55,552 KB
testcase_02 AC 268 ms
59,384 KB
testcase_03 AC 272 ms
59,988 KB
testcase_04 AC 269 ms
59,880 KB
testcase_05 AC 272 ms
59,520 KB
testcase_06 AC 265 ms
59,764 KB
testcase_07 AC 282 ms
59,340 KB
testcase_08 AC 274 ms
59,764 KB
testcase_09 AC 258 ms
57,548 KB
testcase_10 AC 269 ms
58,012 KB
testcase_11 AC 295 ms
60,208 KB
testcase_12 AC 288 ms
60,260 KB
testcase_13 AC 304 ms
60,556 KB
testcase_14 AC 303 ms
59,920 KB
testcase_15 AC 289 ms
60,000 KB
testcase_16 AC 289 ms
59,972 KB
testcase_17 AC 292 ms
60,184 KB
testcase_18 AC 291 ms
62,188 KB
testcase_19 AC 303 ms
60,404 KB
testcase_20 AC 302 ms
60,044 KB
testcase_21 AC 309 ms
60,544 KB
testcase_22 AC 287 ms
59,880 KB
testcase_23 AC 293 ms
59,820 KB
testcase_24 AC 313 ms
60,260 KB
testcase_25 AC 285 ms
59,916 KB
testcase_26 AC 304 ms
59,912 KB
testcase_27 AC 294 ms
60,060 KB
testcase_28 AC 287 ms
59,956 KB
testcase_29 AC 129 ms
55,536 KB
testcase_30 AC 127 ms
55,428 KB
testcase_31 AC 136 ms
55,624 KB
testcase_32 AC 134 ms
55,672 KB
testcase_33 AC 127 ms
56,032 KB
testcase_34 AC 130 ms
55,276 KB
testcase_35 AC 129 ms
55,900 KB
testcase_36 AC 127 ms
55,464 KB
testcase_37 AC 130 ms
55,428 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    static long[] dp;
	public static void main (String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int t = sc.nextInt();
    	int b = -sc.nextInt();
    	StringBuilder sb = new StringBuilder();
    	for (int i = 0; i < t; i++) {
    	    StringBuilder tmp = new StringBuilder();
    	    int n = sc.nextInt();
    	    for (int j = 0; n > 0; j++) {
    	        int mod = n % b;
    	        n /= b;
    	        if (j % 2 == 1 && mod != 0) {
    	            n++;
    	            mod = b - mod;
    	        }
    	        tmp.append(mod);
    	    }
    	    if (tmp.length() == 0) {
    	        tmp.append("0");
    	    }
    	    sb.append(tmp.reverse()).append("\n");
    	}
    	System.out.print(sb);
    }
}
0