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.
# Enter your code here. Read input from STDIN. Print output to STDOUTimportmathdefcheck(n):foriinrange(2,int(math.sqrt(n))+1):ifn%i==0:returnFalsereturnTruep=[]a=[0]*1001foriinrange(2,1001):ifa[i]==0:ifcheck(i):p.append(i)forjinrange(2*i,1001,i):a[j]=1n=[0]*1001n[0]=1forn1inp:foriinrange(n1,1001):n[i]+=n[i-n1]t=int(input())whilet>0:m=int(input())print(n[m])t-=1
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #77: Prime summations
You are viewing a single comment's thread. Return to all comments →
python