1064 朋友数 (20 point(s))

#include <bits/stdc++.h>
using namespace std;

int main() {
	int n, tmp, a, b, c, d, first = 0;
	set<int> fri;
	cin >> n;
	
	while(n--){
		cin >> tmp;
		a = tmp % 10;
		b = tmp / 10 % 10;
		c = tmp / 10 / 10 % 10;
		d = tmp / 10 / 10 / 10; 
		fri.insert(a + b + c + d);
	}
	cout << fri.size() << endl;
	for(auto f: fri) cout << (first++ ? " " : "") << f;
}
上一篇:poj 1064(注意二分搜索变形中l,r,mid的取值和结果取mid还是l 抑或r )


下一篇:1064朋友数