結果
| 問題 | No.782 マイナス進数 | 
| コンテスト | |
| ユーザー |  ngtkana | 
| 提出日時 | 2020-03-30 23:06:18 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 26 ms / 2,000 ms | 
| コード長 | 627 bytes | 
| コンパイル時間 | 6,657 ms | 
| コンパイル使用メモリ | 193,060 KB | 
| 最終ジャッジ日時 | 2025-01-09 11:09:20 | 
| ジャッジサーバーID (参考情報) | judge3 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 36 | 
ソースコード
#include<bits/stdc++.h>
using lint=long long;
using real=long double;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint q,b;std::cin>>q>>b;b=-b;
    while(q--){
        lint x;std::cin>>x;
        if(x==0){
            std::cout<<0<<'\n';
            continue;
        }
        std::string s;
        while(x){
            lint r=x%b;
            if(r<0)r+=b;
            s.push_back('0'+r);
            x-=r;
            x/=b;
            x*=-1;
        }
        std::cout<<std::string(s.rbegin(),s.rend())<<'\n';
    }
}
            
            
            
        