#include<bits/stdc++.h>
#define N 1000000
#define ll unsigned long long int
using namespace std;
int p[N+1];
void seive()
{
ll i, j, l = sqrt(N);
for(i=1; i<=N; i++)
p[i] = i;
for(i=4; i<=N; i+=2)
p[i] = 2;
for(i=3; i*i<=N; i++)
{
if(p[i] == i)
{
for(j=i*i; j<=N; j+=i)
{
if(p[j] == j)
p[j] = i;
}
}
}
}
int a[100+1];
vector<ll>b[100+1];
void factorize()
{
int i, j;
for(i=0; i<=100; i++)
a[i] = 0;
for(i=2; i<=100; i++)
{
ll n = i;
while(n > 1)
{
ll t = p[n];
a[t] += 1;
n/=p[n];
}
for(j=2; j<=100; j++)
{
if(a[j] != 0)
b[i].push_back(a[j]);
}
}
}
int main()
{
seive();
factorize();
ll n, i, flag = 0;
while(cin >> n && n > 0)
{
printf("%3ld! =", n);
if (b[n].size() > 15)
flag = 0;
else
flag = 15;
for(i=0; i<b[n].size(); i++)
{
printf("%3ld", b[n][i]);
flag++;
if (flag == 15)
printf("\n%6c",' ');
}
cout << endl;
}
return 0;
}
#define N 1000000
#define ll unsigned long long int
using namespace std;
int p[N+1];
void seive()
{
ll i, j, l = sqrt(N);
for(i=1; i<=N; i++)
p[i] = i;
for(i=4; i<=N; i+=2)
p[i] = 2;
for(i=3; i*i<=N; i++)
{
if(p[i] == i)
{
for(j=i*i; j<=N; j+=i)
{
if(p[j] == j)
p[j] = i;
}
}
}
}
int a[100+1];
vector<ll>b[100+1];
void factorize()
{
int i, j;
for(i=0; i<=100; i++)
a[i] = 0;
for(i=2; i<=100; i++)
{
ll n = i;
while(n > 1)
{
ll t = p[n];
a[t] += 1;
n/=p[n];
}
for(j=2; j<=100; j++)
{
if(a[j] != 0)
b[i].push_back(a[j]);
}
}
}
int main()
{
seive();
factorize();
ll n, i, flag = 0;
while(cin >> n && n > 0)
{
printf("%3ld! =", n);
if (b[n].size() > 15)
flag = 0;
else
flag = 15;
for(i=0; i<b[n].size(); i++)
{
printf("%3ld", b[n][i]);
flag++;
if (flag == 15)
printf("\n%6c",' ');
}
cout << endl;
}
return 0;
}
Comments
Post a Comment