Submission
Status:
PPPPPPPPPP
Subtask/Task Score:
100/100
Score: 100
User: NANO..
Problemset: เลขฐานเบญจภาคได้ดุล
Language: cpp
Time: 0.003 second
Submitted On: 2026-11-16 17:26:12
#include<bits/stdc++.h>
using namespace std;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int x;
cin >> x;
while (x--)
{
int n,key=1;
string s="";
cin >> n;
if(n==0){
cout << 0 << '\n';
continue;
}
if(n<0) key=-1;
n=abs(n);
while (n>0)
{
if(n%5==0){
cout << "0 ";
n/=5;
}else if(n%5==1){
cout << 1*key << ' ';
n/=5;
}else if(n%5==2){
cout << 2*key << ' ';
n/=5;
}else if(n%5==3){
cout << -2*key << ' ';
n=(n+2)/5;
}else{
cout << -1*key << ' ';
n=(n+1)/5;
}
}
cout << '\n';
}
return 0;
}
/*
a*b^c+d*e^f
*/