cdtsgsz
BAN USER
Comments (3)
Reputation 0
Page:
1
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
0
of 0 vote
I suppose I found a method work with better time approach(I think this comes from Eratosthenes sieve):
void find_prime_and_print_factors(std::std::vector<int> _return,int n)
{
int range = 2*n+1;
std::std::vector<int> num[range];
for(int i=1;i<range;i++)
{
int calnum = i+1;
if(num[i].isEmpty())
{
for(int j=2;j*calnum<=range;j++)
num[j*calnum-1].push_back(calnum);
_return.push_back(calnum);
}else{
std::cout<<calnum<<": ";
std::std::vector<int>::iterator itr;
for(itr=num[i].begin();itr!=num[i].end();++itr)
std::cout<<*itr<<" ";
std::cout<<std::endl;
}
}
}
Page:
1
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
using kmp algorithmn
- cdtsgsz October 17, 2012