1064 朋友数 (20 point(s))

时间:2021-09-07 15:26:41   收藏:0   阅读:7
#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;
}

原文:https://www.cnblogs.com/Atl212/p/15236625.html

评论(0)
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!