結果

問題 No.782 マイナス進数
ユーザー 1119_29161119_2916
提出日時 2019-01-22 14:39:53
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 28 ms / 2,000 ms
コード長 1,354 bytes
コンパイル時間 1,472 ms
コンパイル使用メモリ 146,536 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-10-13 17:40:57
合計ジャッジ時間 4,054 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd


string solve(int k, int n)
{
    if (!n) return "0";
    string ret = "";
    int mod = abs(k);
    while (n) {
        int m = (n % mod + mod) % mod;
        ret += m+'0';
        n = (n - m) / k;
    }
    reverse(all(ret));
    return ret;
}

signed main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    int2(t, b);

    while (t--) {
        Int(n);
        cout << solve(b, n) << endl;
    }


    return 0;
}
0