题目链接:
https://pintia.cn/problem-sets/994805260223102976/problems/994805267416334336
AC代码:
#include <bits/stdc++.h>
using namespace std;
int main(){
int N;
set<int> s;
scanf("%d",&N);
while(N--){
int tmp,sum=0;
scanf("%d",&tmp);
while(tmp){
sum+=tmp%10;
tmp/=10;
}
s.insert(sum);
}
int num=s.size();
int i=0;
printf("%d\n",num);
for(set<int>::iterator it=s.begin();it!=s.end();it++){
cout<<*it;
if(i!=num-1){
printf(" ");
}
i++;
}
}