4673번: 셀프 넘버

문제접근🤔


놓쳤던 부분😅


코드😁


2160 KB

12 ms

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(void)
{
	vector<int> v;
	int i = 0;
	int n;
	int tmp;

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	while (++i <= 10000)
	{
		n = i;
		tmp = n;
		while (n >= 10)
		{
			tmp += n % 10;
			n /= 10;
		}
		tmp += n;
		v.push_back(tmp);
	}
	sort(v.begin(), v.end());
	i = 0;
	while (++i <= 10000)
	{
		if (find(v.begin(), v.end(), i) != v.end())
			continue ;
		else
			cout << i << "\\n";
	}
	return (0);
}