Cod sursa(job #3224721)

Utilizator AndreasBossGamerBaragau Andreas AndreasBossGamer Data 15 aprilie 2024 22:04:02
Problema Radiatie Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.56 kb
#include <iostream>
#include <unordered_map>

using namespace std;

unordered_map<int, int> f;

void factori(int nr)
{
	f[nr]++;
	for (int d = 2; d * d <= nr; d++)
	{
		int p = 0;
		while (nr % d == 0)
		{
			nr /= d;
			p++;
		}
		f[d] += p;
	}
}

int main()
{
	for (int i = 1; i <= 5; i++)
	{
		int x;
		cin >> x;
		f.clear();
		factori(x);
		cout << "\n\n";
		unordered_map<int, int>::iterator it;
		for (it = f.begin(); it != f.end(); it++)
		{
			cout << it->first << " " << it->second << " ;  ";
		}
		cout << "\n\n";
	}
	
}