John's solution got Hacked
Practice
0 (0 votes)
Hard
Problem
51% Success 255 Attempts 50 Points 1s Time Limit 256MB Memory 1024 KB Max Code

    John was recently giving a contest on Codeforces, which he was unsure weather it would get accepted or would result in TLE(Time Limit Exceeded), so he optimised the solution a bit and submitted and pretests passed for his solution with execution time 2396ms(Time Limit:- 2.5 sec).Although, just 5 mins before the contest ended, His solution got Hacked due to TLE. The question was simply to find prime factors of a number.

    Now, he asked your help, as he got frustrated with the contraints of the problem.

INPUT:

First line contains a single integer denoting the number of test cases.

Each test case contains a single line containing a single integer N whose factors you have to find.

OUTPUT:

First line of each test contains a single integer say S denoting the number of prime factors of that number.

Second line consists of S integers, the prime factors of the number, in ascending order

NOTE:- For N=1, print '0' in one line and an empty line.

CONSTRAINTS:

No of Test cases <=105

1<=N<=2*107

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:50
Tags:
HardRecruitNumber TheoryReadyGrammar-VerifiedMathematicsSimulationApprovedFactorization
Points:50
Tags:
HardNumber TheoryInteger factorizationData StructuresMathematicsSegment treeSieve
Points:50
5 votes
Tags:
HardNumber TheoryAlgorithmsMathematicsOpenApproved