pat1059 Prime Factors

#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define N 100005
#define ll long long
using namespace std;
int ok[100000],prime[20000];
int cnt = 0;
vector >v;
void pre()
{
	memset(ok,0,sizeof(ok));
	for(int i = 2;i<100000;i++)
	{
		if(!ok[i])
		{
			prime[cnt++] = i;
			for(int j = i;j<100000;j+=i)ok[j] = 1;
		}
	}
}
int main()
{
	int x,y;
	pre();
	while(scanf("%d",&x)!=EOF)
	{
		y = x;
		v.clear();
		if(x == 1)
		{
			printf("1=1\n");
			continue;
		}
		int i = 0;
		while(prime[i]*prime[i]<=x)
		{
			int num = 0;
			while(x%prime[i] == 0)
			{
				num++;
				x/=prime[i];
			}
			if(num)v.push_back(make_pair(prime[i],num));
			i++;
		}
		if(x!=1)v.push_back(make_pair(x,1));
		printf("%d=",y);
		for(i = 0;i

你可能感兴趣的:(PAT)