Always inadvertently, looking back on the other side, even if found a long scene.

Title Description

Tongtong has just learned the factorial of natural number N: factorial (N!) is defined as the product of all integers from 1 to N, such as 5! = 5 *4 *3 *2 *1 = 120. As the number of N increases, N! Grows very fast, 5! = 120, 10! = 3628800. Tongtong has come up with a way to enumerate such a large number: instead of directly listing the number, it lists the number of times each prime factor appears in the number in order. For example, 825 can be described as (01201), which means the decomposition of prime factors for 825. There are 0 2, 1 3, 2 5, 0 7, 1 11 of these prime factors. Please compile a program to read in the value of N to help Tongtong output the number of prime factors contained in N! In order.

input

It contains only one number N(2 < N < 100000).

output

A sequence of the number of prime factors (starting with the smallest prime) contained in an N! Separated by a space between the number and the number. (Note: There is no need to output extra returns and spaces at the end of this question.)

sample input

Duplicate sample data

53

sample output

49 23 12 8 4 4 3 2 2 1 1 1 1 1 1 1
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <ctime>
#include <cctype>
#include <bitset>
#include <utility>
#include <sstream>
#include <complex>
#include <iomanip>
typedef long long ll;
using namespace std;
int prime,ct=0,flag;
int x;
int main()
{
for(int i=2; i<=100000; i++)
{
if(!flag[i])
prime[ct++]=i;
for(int j=0; j<ct&&prime[j]*i<=100000; j++)
{
flag[prime[j]*i]=1;
if(i%prime[j]==0)
break;
}
}
scanf("%d",&x);
int fg=1;
for(int j=0; j<ct&&prime[j]<=x; j++)
{
int xz=prime[j];
int ans=0;
while(1)
{
if(x/xz!=0)
ans+=x/xz;
else
break;
xz=xz*prime[j];
}
if(fg==0)
printf(" ");
else
fg=0;
printf("%d",ans);
}
return 0;
}

Posted by trinitywave on Tue, 08 Oct 2019 17:24:05 -0700