結果

問題 No.782 マイナス進数
ユーザー PachicobuePachicobue
提出日時 2019-01-11 22:02:01
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,334 bytes
コンパイル時間 2,236 ms
コンパイル使用メモリ 202,464 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-08-20 06:21:40
合計ジャッジ時間 4,501 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 23 ms
4,380 KB
testcase_03 AC 24 ms
4,376 KB
testcase_04 AC 26 ms
4,380 KB
testcase_05 AC 23 ms
4,376 KB
testcase_06 AC 22 ms
4,376 KB
testcase_07 AC 31 ms
4,380 KB
testcase_08 AC 24 ms
4,380 KB
testcase_09 AC 22 ms
4,380 KB
testcase_10 AC 22 ms
4,376 KB
testcase_11 AC 31 ms
4,380 KB
testcase_12 AC 30 ms
4,376 KB
testcase_13 AC 46 ms
4,376 KB
testcase_14 AC 29 ms
4,380 KB
testcase_15 AC 30 ms
4,380 KB
testcase_16 AC 29 ms
4,376 KB
testcase_17 AC 37 ms
4,376 KB
testcase_18 AC 29 ms
4,376 KB
testcase_19 AC 34 ms
4,380 KB
testcase_20 AC 29 ms
4,380 KB
testcase_21 AC 37 ms
4,376 KB
testcase_22 AC 31 ms
4,376 KB
testcase_23 AC 28 ms
4,380 KB
testcase_24 AC 46 ms
4,380 KB
testcase_25 AC 29 ms
4,376 KB
testcase_26 AC 33 ms
4,380 KB
testcase_27 AC 31 ms
4,380 KB
testcase_28 AC 29 ms
4,380 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define show(x) std::cerr << #x << " = " << (x) << std::endl
using ll = long long;
using ld = long double;
constexpr ll MOD = 1000000007LL;
template <typename T>
constexpr T INF() { return std::numeric_limits<T>::max() / 16; }
std::mt19937 mt{std::random_device{}()};
int main()
{
    ll T, B;
    std::cin >> T >> B;
    B = -B;
    for (int i = 0; i < T; i++) {
        ll N;
        std::cin >> N;
        std::vector<int> dig;
        for (; N > 0; N /= B) { dig.push_back(N % B); }
        for (int i = 1; i < dig.size(); i++) {
            if (i % 2 == 1) {
                if (dig[i] == 0) {
                } else {
                    dig[i] = B - dig[i];
                    if (i == dig.size() - 1) {
                        dig.push_back(1);
                    } else {
                        dig[i + 1]++;
                    }
                }
                if (dig[i + 1] == B) {
                    dig[i + 1] = 0;
                    if (i + 2 == dig.size()) {
                        dig.push_back(1);
                    } else {
                        dig[i + 2]++;
                    }
                }
            }
        }
        std::reverse(dig.begin(), dig.end());
        for (const int d : dig) { std::cout << d; }
        std::cout << std::endl;
    }

    return 0;
}
0