Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: eefirefire

Problemset: เลขฐานเบญจภาคได้ดุล

Language: cpp

Time: 0.003 second

Submitted On: 2026-09-20 08:34:33

/*
TASK: quinary
LANG: C++
AUTHOR: YourName YourLastName
CENTER: SUT
*/
#include <iostream>
#include <vector>

using namespace std;

int main() {
    cin.tie(nullptr)->sync_with_stdio(false);

    int n;
    if (!(cin >> n)) return 0;

    for (int tc = 0; tc < n; tc++) {
        int x;
        cin >> x;

        if (x == 0) {
            cout << 0 << '\n';
            continue;
        }

        vector<int> digits;

        while (x != 0) {
            int rem = ((x % 5) + 5) % 5;

            if (rem > 2) {
                rem -= 5;
            }

            digits.push_back(rem);
            x = (x - rem) / 5;
        }

        int total_digits = digits.size();
        for (int i = 0; i < total_digits; i++) {
            cout << digits[i] << (i == total_digits - 1 ? "" : " ");
        }
        cout << '\n';
    }

    return 0;
}