fork(3) download
#include 
#include 
#include
#include 
#include 

using namespace std;
int best[10000010];
bitset <10000010> isComposite;
void sieve ()
{
    for (int i=2 ;i<=3163 ;i++)
    {
        if (i%2==0 && i!=2) continue;
        if (isComposite[i]) continue;
        for (int j=i*i ;j<=10000000;j+=i)
        {
            isComposite[j]=1;
            if (best[j]==0) best[j] = j/i;
        }
    }
    return ;
}
void solve (int num)
{
    int ans = num;
    while (best[ans]!=0)
    {
        printf(" x %d",ans/best[ans]);
        ans = best[ans];
    }
    printf(" x %d",ans);
    return ;
}
int main ()
{
    sieve();
    int n;
    while (cin >> n)
    {
        printf("1");
        if (!(isComposite[n])) printf(" x %d",n);
        else solve(n);
        cout << endl;
    }
    return 0;
}
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout

Standard output is empty