Sphere Online Judge



SPOJ Problem Set (classical)

10818. Medium Factorization

Problem code: FACTCG2

The task in this problem is to write a number in a multiplication of prime numbers separated by “ x”. You need to put the

number 1 in this multiplication.


Input

The input consists of several lines.

Each line consists of one integer N (1 <= N <= 10^7) .


Output

For each line you need to output the factorization separated by “ x” and including 1.


Sample Input

1

2

4

8

Sample Output

1
1 x 2
1 x 2 x 2
1 x 2 x 2 x 2

Added by:Phyllipe Medeiros
Date:2012-02-26
Time limit:0.517s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel Pentium G860 3GHz)
Languages:All except: SCM chicken

hide comments
2015-01-18 17:36:40 Jumpy
After, So Many Tries Got AC.
Things to be kept in mind before solving the problem , is not to use too many looping while dividing the number with desirable prime number and afterwards keep on looking for next correct prime number. I think the input file is having large number of data. So, It is better to keep it as simple as possible.

Last edit: 2015-01-18 17:43:18
2015-01-12 02:17:48 computer science
what is number of lines ?

re(vamsi): read till EOF. check the documentation of your language if you don't know how to read till EOF

But if you are c/c++ folk, then this might be helpful
while(scanf("%i",&n) != EOF ) {
//statement
}

Last edit: 2015-01-18 17:40:55
2015-01-05 13:49:42 epsilon
finally done.......after lots of tle
2015-01-02 20:28:03 arpankumarmishra1994@gmail.com
what does several lines mean?

--ans(Francky)--> You have to read until End Of File (EOF).

Last edit: 2015-01-02 20:36:20
2014-12-27 19:55:02 Hot-Shot
guys sieve works properly
but you have format output " x " fashion rather than " x"...I get AC 5 attempts earlier if know that...
2014-11-03 04:26:18 avinish chandra
12799109-cannot understand why i am getting wrong answer.plz help
2014-10-20 19:38:59 simple
http://ideone.com/payrlT
It would be helpful if someone told me countercase for WA.
PLSS PLSS

Last edit: 2014-10-20 20:49:46
2014-10-05 06:19:27 Rahul Ranjan
getting WA on 4th test case....Suggest some test cases..I m using sieve...link----> http://ideone.com/nUC7sH

Last edit: 2014-10-05 07:23:30
2014-09-18 00:05:18 Baojun Wang
same algorithm, C++ passed, Haskell version TLE, even haskell version is almost the same on my machine. Time to upgrade haskell compiler on SPOJ?

Last edit: 2014-09-18 00:24:41
2014-08-21 10:00:32 pushkar
can anyone suggest some input.. My program is failing for judge 4.
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.