|
- #include <stdio.h>
- int main()
- {
- int n,t,gud=0,i,j;
- int num[21],reco[21],geno[21],c[21]={0};
- long long int ans=0;
- scanf("%d",&n);
- for(i=0;i<=n-1;i++)
- {
- scanf("%d",&num[i]);
- }
- for(i=0;i<=n-1;i++)
- {
- reco[i]=num[i];
- geno[i]=num[i];
- while(reco[i]/10!=0)
- {
- reco[i]=reco[i]/10;
- c[i]++;
- }
- c[i]++;
- if(gud<c[i])
- gud=c[i];
- }
- for(i=0;i<=n-1;i++)
- for(j=c[i];j<=gud-1;j++)
- geno[i]=geno[i]*10;
- for(i=0;i<=n-1;i++)
- for(j=i+1;j<=n-1;j++)
- if(geno[i]>geno[j])
- {
- t=geno[i];
- geno[i]=geno[j];
- geno[j]=t;
-
- t=num[i];
- num[i]=num[j];
- num[j]=t;
- }
- t=1;
- for(i=0;i<=n-1;i++)
- {
- if(i!=0)
- for(j=0;j<=c[i-1]-1;j++)
- t=t*10;
- ans=ans+num[i]*t;
- }
- printf("%d",ans);
- return 0;
- }
复制代码 |
|