結果
問題 |
No.782 マイナス進数
|
ユーザー |
![]() |
提出日時 | 2025-03-20 18:42:22 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 85 ms / 2,000 ms |
コード長 | 570 bytes |
コンパイル時間 | 143 ms |
コンパイル使用メモリ | 82,564 KB |
実行使用メモリ | 77,492 KB |
最終ジャッジ日時 | 2025-03-20 18:42:34 |
合計ジャッジ時間 | 4,694 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 36 |
ソースコード
import sys def convert_to_negative_base(n, b): if n == 0: return '0' digits = [] m = abs(b) while n != 0: r = n % m digits.append(r) n = (n - r) // b # Reverse to get the correct order return ''.join(map(str, reversed(digits))) def main(): input = sys.stdin.read().split() idx = 0 T = int(input[idx]) idx +=1 B = int(input[idx]) idx +=1 for _ in range(T): N = int(input[idx]) idx +=1 print(convert_to_negative_base(N, B)) if __name__ == '__main__': main()