結果
| 問題 | No.782 マイナス進数 |
| コンテスト | |
| ユーザー |
norioc
|
| 提出日時 | 2025-11-27 22:28:24 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 137 ms / 2,000 ms |
| + 181µs | |
| コード長 | 420 bytes |
| 記録 | |
| コンパイル時間 | 246 ms |
| コンパイル使用メモリ | 96,092 KB |
| 実行使用メモリ | 85,376 KB |
| 最終ジャッジ日時 | 2026-07-17 00:15:42 |
| 合計ジャッジ時間 | 7,399 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 36 |
ソースコード
def negative_base(n: int, base: int) -> list[int]:
assert base < -1
if n == 0: return [0]
res = []
x = n
while x != 0:
x, m = divmod(x, base)
if m < 0:
m += abs(base)
x += 1
res.append(m)
res.reverse()
return res
T, B = map(int, input().split())
for _ in range(T):
N = int(input())
ans = negative_base(N, B)
print(*ans, sep='')
norioc