We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Project Euler #193: Squarefree Numbers
Project Euler #193: Squarefree Numbers
Sort by
recency
|
25 Discussions
|
Please Login in order to post a comment
My code is passing 0 and 1 test cases but failing reaminig all test cases can anyone one help me out. My code is absolutely fine but i don't know why its failing test cases. def prime(k): for i in range(2,k): if k%i==0: return False return True
n,m=list(map(int,input().split())) l=[i for i in range(1,n+1)] for i in range(1,n+1): for j in range(2,i): if prime(j): if i%(j**m)==0: l.remove(i) else: continue print(len(l))
time out!!!!!!!!!!!!!!!!!
my brain hurts... and my guess is that there is a single source that solves this problem in space(s)<=500Mb and time(t)<=2s.
The approach appears to be key. Even with a fast isPrime and a fast countInclusionExclusion this ain't gonna work for 10E18 (ie 1000000000000000000000 2 [and definitely not 1])
So to my first point - [guess:] there is a single (probably simple) way to solve this problem... it will not be pretty... or it will be way obscure...
My code which is passing few test cases, gives wrong answer in few test cases and times out in rest of the cases.
package practiceQuestion; import java.io.; import java.util.; import java.text.; import java.math.; import java.util.regex.*;
public class Trys {
} // can anyone tell me why timeout is giving plz solve this