Submission
Status:
TTTTTTTTTT
Subtask/Task Score:
0/100
Score: 0
User: cheetah
Problemset: C.Sort Number
Language: cpp
Time: 1.095 second
Submitted On: 2026-07-10 00:08:36
#include<bits/stdc++.h>
using namespace std;
int main () {
ios_base::sync_with_stdio(0);
cin.tie(0);
int t;
cin >> t;
int sum[t] = {}, ans[t];
for (int i = 0; i < t; ++i) {
ans[i] = 1;
}
for (int i = 0; i < t; ++i) {
int n;
string s;
cin >> n >> s;
int nbase10 = 0;
for (int j = 0; j < s.size(); ++j) {
if (s[j] >= 65) {
nbase10 = nbase10 * n + 10 + s[j] - 'A';
}
else {
nbase10 = nbase10 * n + s[j] - '0';
}
}
// cout << "nbase10 = " << nbase10 << "\n";
int a = 2, cnt = 1, x = 1;
while (nbase10 > 1) {
if (nbase10 % a == 0) {
nbase10 = nbase10 / a;
cnt += x * a;
x = x * a;
}
else {
ans[i] *= cnt;
++a;
cnt = 1;
x = 1;
}
}
ans[i] *= cnt;
}
sort(ans, ans + t, greater());
for (int i = 0; i < t; ++i) {
cout << ans[i] << "\n";
}
return 0;
}