其他分享
首页 > 其他分享> > XTU OJ1328 数码和

XTU OJ1328 数码和

作者:互联网

#include<stdio.h>
#include<string.h>
/*
3
17
20
1000000000
*/ 
int b[20];
int c[10000];
typedef long long ll;
int main()
{
    int k;
    scanf("%d",&k);
    while(k--)
    {
        ll a,p;
        scanf("%lld",&a);
        for(int i=2;i<=16;i++){
            p=a;
            while(p)
            {
                b[i]+=p%i;
                p=p/i;                
            }
            c[b[i]]++;
        }
        int time=c[0];
        for(int i=1;i<=9999;i++){
            if(c[i]>time) time=c[i];    //找到出现次数最多为time; 
        }
        printf("%d\n",time);
//有可能出现次数会有重复    
        for(int i=0;i<=9999;i++){
            if(c[i]==time) 
            {
                printf("%d",i);    
                for(int j=2;j<=16;j++){
                    if(b[j]==i)    printf(" %d",j); 
                }
                printf("\n");
            }
        }
        memset(b,0,sizeof(b));
        memset(c,0,sizeof(c));
    }
    return 0;
} 

标签:XTU,20,数码,int,ll,long,OJ1328,time,include
来源: https://blog.csdn.net/qq_60755126/article/details/121802179