英文版题目:https://pintia.cn/problem-sets/994805342720868352/problems/994805352925609984
中文版题目:https://pintia.cn/problem-sets/994805260223102976/problems/994805267416334336
1 #include<iostream> 2 #include<map> 3 using namespace std; 4 5 int main() { 6 int n,cnt = 0,flag = 0; 7 cin>>n; 8 map<int,bool> mp; 9 for(int i = 0; i < n; ++i) { 10 int t,sum = 0; 11 cin>>t; 12 while(t) { 13 sum += t % 10; 14 t /= 10; 15 } 16 if(mp[sum] == false) cnt++,mp[sum] = true; 17 } 18 cout<<cnt<<endl; 19 for(auto it:mp) { 20 if(flag++ != 0) printf(" "); 21 cout<<it.first; 22 } 23 return 0; 24 }
原文:https://www.cnblogs.com/keep23456/p/12519927.html