結果
| 問題 | No.782 マイナス進数 | 
| コンテスト | |
| ユーザー |  ei1333333 | 
| 提出日時 | 2019-01-11 21:36:29 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 45 ms / 2,000 ms | 
| コード長 | 433 bytes | 
| コンパイル時間 | 1,927 ms | 
| コンパイル使用メモリ | 193,260 KB | 
| 最終ジャッジ日時 | 2025-01-06 20:17:24 | 
| ジャッジサーバーID (参考情報) | judge1 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 36 | 
ソースコード
#include<bits/stdc++.h>
using namespace std;
const static inline void rec(int data, int base) {
  if(data == 0) return;
  int next = abs(data) % base;
  if(data < 0) next = (base - next) % base;
  rec((data - next) / -base, base);
  cout << next;
}
int main() {
  int T, B;
  cin >> T >> B;
  while(T--) {
    int N;
    cin >> N;
    if(N == 0) {
      cout << "0\n";
      continue;
    }
    rec(N, -B);
    cout << endl;
  }
}
            
            
            
        