結果

問題 No.782 マイナス進数
ユーザー potoooooooopotoooooooo
提出日時 2019-01-29 23:50:45
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 44 ms / 2,000 ms
コード長 477 bytes
コンパイル時間 2,025 ms
コンパイル使用メモリ 170,904 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-12 01:39:19
合計ジャッジ時間 3,718 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main() {
    int t, b; cin >> t >> b;
    for (int ti = 0; ti < t; ti++) {
        int n; cin >> n;
        deque<int> v;
        while (n) {
            int c = (n % b < 0) ? (n % b + abs(b)) : (n % b);
            n -= c;
            v.push_front(c);
            n /= b;
        }
        for (int i = 0; i < v.size(); i++) {
            cout << v[i];
        }
        if (v.empty()) cout << 0;
        cout << endl;
    }
}
0