結果

問題 No.782 マイナス進数
ユーザー srjywrdnprkt
提出日時 2024-02-09 18:48:33
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 33 ms / 2,000 ms
コード長 517 bytes
コンパイル時間 2,268 ms
コンパイル使用メモリ 195,088 KB
最終ジャッジ日時 2025-02-19 03:04:57
ジャッジサーバーID
(参考情報)
judge5 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    ll T, B, N;
    cin >> T >> B;
    while(T--){
        cin >> N;
        ll x;
        string s="";
        while(N!=0){
            x = N%B;
            if (x < 0) x -= B;
            s += char('0'+x);
            N -= x;
            N /= B;
        }
        if (s == "") s = "0";
        reverse(s.begin(), s.end());
        cout << s << endl;
    }

    return 0;
}
0