結果

問題 No.782 マイナス進数
ユーザー Mcpu3Mcpu3
提出日時 2020-04-05 11:12:25
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,421 ms / 2,000 ms
コード長 575 bytes
コンパイル時間 3,351 ms
コンパイル使用メモリ 71,804 KB
実行使用メモリ 68,076 KB
最終ジャッジ日時 2023-09-16 06:33:35
合計ジャッジ時間 29,098 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
55,900 KB
testcase_01 AC 128 ms
56,196 KB
testcase_02 AC 573 ms
61,104 KB
testcase_03 AC 662 ms
61,020 KB
testcase_04 AC 704 ms
61,608 KB
testcase_05 AC 611 ms
61,392 KB
testcase_06 AC 570 ms
61,292 KB
testcase_07 AC 847 ms
64,940 KB
testcase_08 AC 613 ms
61,236 KB
testcase_09 AC 565 ms
61,716 KB
testcase_10 AC 587 ms
62,888 KB
testcase_11 AC 837 ms
64,812 KB
testcase_12 AC 779 ms
61,652 KB
testcase_13 AC 1,421 ms
68,076 KB
testcase_14 AC 779 ms
62,124 KB
testcase_15 AC 835 ms
65,408 KB
testcase_16 AC 800 ms
63,680 KB
testcase_17 AC 1,106 ms
66,728 KB
testcase_18 AC 787 ms
63,636 KB
testcase_19 AC 985 ms
65,476 KB
testcase_20 AC 786 ms
61,556 KB
testcase_21 AC 1,035 ms
66,064 KB
testcase_22 AC 823 ms
62,416 KB
testcase_23 AC 743 ms
61,404 KB
testcase_24 AC 1,383 ms
67,696 KB
testcase_25 AC 792 ms
61,700 KB
testcase_26 AC 921 ms
67,116 KB
testcase_27 AC 876 ms
63,108 KB
testcase_28 AC 735 ms
61,180 KB
testcase_29 AC 139 ms
55,716 KB
testcase_30 AC 139 ms
56,032 KB
testcase_31 AC 169 ms
56,320 KB
testcase_32 AC 176 ms
56,068 KB
testcase_33 AC 138 ms
55,680 KB
testcase_34 AC 149 ms
55,696 KB
testcase_35 AC 157 ms
56,020 KB
testcase_36 AC 148 ms
55,688 KB
testcase_37 AC 155 ms
56,144 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int T = scanner.nextInt(), B = scanner.nextInt();
		for (int i = 0; i < T; i++) {
			int N = scanner.nextInt();
			Deque<Integer> a = new ArrayDeque<Integer>();
			do {
				if (N % B < 0) {
					a.addFirst(N % B - B);
					N += B;
				}
				else a.addFirst(N % B);
				N /= B;
			} while (N != 0);
			for (int j : a) System.out.print(j);
			System.out.println();
		}
	}
}
0