其他分享
首页 > 其他分享> > 1064 朋友数 (20 point(s))

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;
}

标签:tmp,10,20,point,int,fri,1064,cin,std
来源: https://www.cnblogs.com/Atl212/p/15236625.html