Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: konthaina_TH

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

Language: cpp

Time: 0.002 second

Submitted On: 2026-09-26 14:02:38

#include <bits/stdc++.h>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i=0;i<n;i++) {
        cin >> a[i];
    }

    for (int i=0;i<n;i++) {
        if (a[i] == 0) {
            cout << 0 << "\n";
            continue;
        }
        int remain = 0;
        while (a[i] != 0 ) {
            int temp = (a[i] % 5 + 5) % 5;
            a[i] = (a[i] - temp) /5;
            if (temp == 3) {
                temp = -2;
                a[i] += 1;
            }
            else if (temp == 4) {
                temp = -1;
                a[i] += 1;
            }
            cout << temp << ' ';
        }
        cout << "\n";
    }
}