All submissions for this problem are available.
Alice and Bob are studying for their class test together. The topic of the test is Prime Numbers. The preparation is getting too boring for their liking. To make it interesting, they turn it into a game. The winner will get an ice-cream treat from the other.
The game is called Count K-Primes. A number is a k-prime if it has exactly k distinct prime factors. The game is quite simple. Alice will give three numbers A, B & K to Bob. Bob needs to tell Alice the number of K-prime numbers between A & B (both inclusive). If Bob gives the correct answer, he gets a point. If not, Alice gets a point. They play this game T times.
Bob hasn't prepared so well. But he really wants to win the game. He wants you to tell him the correct answer.
First line of input contains a single integer T, the number of times they play. Each game is described in a single line containing the three numbers A,B & K.
For each game, output on a separate line the number of K-primes between A & B.
1 ≤ T ≤ 10000
2 ≤ A ≤ B ≤ 100000
1 ≤ K ≤ 5
Input 4 2 5 1 4 10 2 14 15 2 2 20 3 Output 4 2 2 0
|Tags||july13, memoization, sieve, simple, vamsi_kavala|
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, PYP3, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.