Submission

Status:
----------

Score: 0

User: gay69

Problemset: C.Sort Number

Language: cpp

Time: 0.040 second

Submitted On: 2024-10-15 18:58:53

#include<bits/stdc++.h>
using namespace std;
char a[100005];
vector<long long> vec;

long long solve(long long temp){
    long long s=sqrt(temp);
    long long rem=0;
    for(int i=1;i<=s;i++){
        if(temp%i==0){
            rem=rem+i;
            rem=rem+(int)(temp/i);
        }
    }
    return rem;


}
int main(){
    int q;
    scanf("%d",&q);
    while(q--){
        int x;
        long long t=0, mul = 1;
        scanf("%d %s",&x,a);
        int i = 0;
        while(a[i]!='\0'){
            i++;
        }
        for (int j = i - 1; j >= 0; j--) {
            if('0'<=a[j] &&a[j]<='9'){
                t+=mul*(a[j]-'0');
            }else{
                t+=mul*(a[j]-'A'+10);
            }
            mul *= x;
        }
        vec.push_back(solve(t));
    }

    sort(vec.begin(),vec.end(),greater<long long>());
    for(int i=0;i<vec.size();i++){
        printf("%lld\n",vec[i]);
    }



}