TopCoder problem "AlmostPrime" used in TCHS SRM 33 (Division I Level Three)



Problem Statement

    A number is called "almost prime" if it is a power of a prime number, but is not a prime number itself. Note that 1 is not almost prime. You are given two Strings A and B, both representing integers (without leading zeros). Return the number of integers between A and B, inclusive, that are almost prime.
 

Definition

    
Class:AlmostPrime
Method:count
Parameters:String, String
Returns:int
Method signature:int count(String A, String B)
(be sure your method is public)
    
 

Constraints

-A will represent an integer between 1 and 10^14, inclusive.
-B will represent an integer between A and 10^14, inclusive.
-Both A and B will have no leading zeros.
 

Examples

0)
    
"1"
"10"
Returns: 3
4, 8 and 9 are almost prime here.
1)
    
"1"
"1000"
Returns: 25
2)
    
"5324"
"894739"
Returns: 183

Problem url:

http://www.topcoder.com/stat?c=problem_statement&pm=7867

Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=10767&pm=7867

Writer:

mateuszek

Testers:

PabloGilberto , brett1479 , Olexiy , ivan_metelsky

Problem categories:

Math, Simple Search, Iteration