結果

問題 No.782 マイナス進数
ユーザー puni_kyopropuni_kyopro
提出日時 2019-01-22 22:02:27
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 21 ms / 2,000 ms
コード長 1,267 bytes
コンパイル時間 640 ms
コンパイル使用メモリ 81,632 KB
実行使用メモリ 4,476 KB
最終ジャッジ日時 2023-10-14 09:19:08
合計ジャッジ時間 2,651 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 14 ms
4,348 KB
testcase_03 AC 15 ms
4,348 KB
testcase_04 AC 15 ms
4,348 KB
testcase_05 AC 15 ms
4,352 KB
testcase_06 AC 15 ms
4,348 KB
testcase_07 AC 16 ms
4,348 KB
testcase_08 AC 16 ms
4,352 KB
testcase_09 AC 14 ms
4,352 KB
testcase_10 AC 16 ms
4,348 KB
testcase_11 AC 17 ms
4,348 KB
testcase_12 AC 16 ms
4,348 KB
testcase_13 AC 20 ms
4,348 KB
testcase_14 AC 17 ms
4,348 KB
testcase_15 AC 18 ms
4,348 KB
testcase_16 AC 16 ms
4,352 KB
testcase_17 AC 19 ms
4,352 KB
testcase_18 AC 17 ms
4,348 KB
testcase_19 AC 19 ms
4,348 KB
testcase_20 AC 18 ms
4,352 KB
testcase_21 AC 19 ms
4,352 KB
testcase_22 AC 18 ms
4,352 KB
testcase_23 AC 16 ms
4,348 KB
testcase_24 AC 21 ms
4,348 KB
testcase_25 AC 18 ms
4,348 KB
testcase_26 AC 19 ms
4,352 KB
testcase_27 AC 19 ms
4,348 KB
testcase_28 AC 17 ms
4,352 KB
testcase_29 AC 2 ms
4,352 KB
testcase_30 AC 2 ms
4,352 KB
testcase_31 AC 2 ms
4,348 KB
testcase_32 AC 2 ms
4,476 KB
testcase_33 AC 1 ms
4,352 KB
testcase_34 AC 1 ms
4,348 KB
testcase_35 AC 1 ms
4,348 KB
testcase_36 AC 1 ms
4,348 KB
testcase_37 AC 1 ms
4,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll,ll> pll;
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
#define MOD 1000000007
#define ARRAY_MAX 100005

const int INF = 1e9+7;


int main(){

    int t,b;
    cin >> t >> b;
    for(int i = 0;i < t;i++){
        int tmp;
        cin >> tmp;
        if(tmp == 0){
            cout << "0" << endl;
            continue;
        }
        string s;
        while(tmp != 0){
            int mod = tmp%b;
            tmp /= b;
            if(mod < 0){
                tmp++;
                mod -= b;
            }
            s.push_back('0'+mod);
        }
        //s.push_back('0'+tmp);
        reverse(s.begin(),s.end());
        cout << s << endl;
    }







    return 0;
}
0