Submission

Status:

-PPPPPPP-P

Subtask/Task Score:

80/100

Score: 80

User: NANO..

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

Language: cpp

Time: 0.004 second

Submitted On: 2026-10-19 16:53:55

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

void qui(int n,int key){
    if(n==0) return;
    if(n%5==0){
        cout << 0 << " ";
        qui(n/5,key);
    }else if (n%5==1)
    {
        cout << 1*key << " ";
        qui(n/5,key);
    }else if (n%5==2)
    {
        cout << 2*key << " ";
        qui(n/5,key);
    }else if (n%5==3)
    {
        cout << -2*key << " ";
        qui((n+2)/5,key);
    }else if (n%5==4)
    {
        cout << -1*key << " ";
        qui((n+1)/5,key);
    }
    
}

int main(){
     ios::sync_with_stdio(0);cin.tie(0);
    int x;
    cin >> x;
    for (int i = 0; i < x; i++)
    {
        int key=1,n;
        cin >> n;
        if(n<0) key=-1;
        qui(abs(n),key);
        cout << '\n';
    }
    return 0;
}