# Facebook Hacker Cup Round 1 homework (test data included)

Source: Internet
Author: User
Tags fsm

Title Description:

HomeworkTen points

Your first-grade math teacher, Mr book, have just introduced you-an amazing new concept-primes! According to your notes, a prime is a positive an integer greater than 1 that's divisible by only 1 and itself.

Primes seem fun, but without giving you and your 6-year-old colleagues time to consider their implications, he ' s promptly Gone on to define another term:primacity. He explains, the primacity of an integer is the number of distinct primes which divide it. For example, the primacity of 2 (as it's divisible by primes 2 and 3), the primacity of 550 is 3 (as it s divisible By primes 2, 5, and one), and the primacity of 7 is 1 (as the only prime it's divisible by IS 7).

Following his lesson, Mr. Book have given you homework with some rather mean questions of the following Form:given 3 Integ ERs a, b, and K, how many integers in the inclusive range [a, b] has A prima City of exactly K?

Mr Book probably expects he little homework assignment to take a and your classmates the rest of the year to complete, Giving him time to slack off and nap during the remaining math classes. However, want to learn more things from him instead! Can you use the skills your ' ve learned in your First-grade computer science classes to finish Mr. Book's homework before to Morrow ' s math class?

Input

Input begins with an integer T, the number of homework questions. For each question, there are one line containing 3 space-separated integers: A, B, and K.

Output

For the i-th question, print a line containing ' case #I: ' followed by the number of integers in the incl Usive range [a, B] with A primacity of K.

Constraints

1 ≤ T ≤100
2 ≤ AB ≤107
1 ≤ K ≤109

Explanation of Sample

In the first test case, the numbers in the inclusive range [5, +] with primacity 2 is 6, ten,, and 15. All other numbers in this range has primacity 1.

Example Input·Example Output·
`55 15 22 10 124 42 31000000 1000000 11000000 1000000 2`
`Case #1:5Case #2:7Case #3:2Case #4:0Case #5:1`

Problem Solving Ideas:

The problem is very water, and it's too much to make a watch. This table records how many factorization a number has. Tables are treated in a similar way to the number of sieve primes.

Title Code:

`#include <set> #include <map> #include <queue> #include <math.h> #include <vector># Include <string> #include <stdio.h> #include <string.h> #include <stdlib.h> #include < iostream> #include <cctype> #include <algorithm> #define EPS 1e-10#define pi acos ( -1.0) #define INF 107374182#define INF64 1152921504606846976#define LC l,m,tr<<1#define RC m + 1,r,tr<<1|1#define Zero (a) fabs (a) <eps#define iabs (x) ((x) > 0? (x):-(x)) #define CLEAR1 (A, X, SIZE) memset (A, X, sizeof (a[0]) * (min (size,sizeof (a))) #define ClearAll (A, X) memset (A, X , sizeof (a)) #define MEMCOPY1 (A, X, SIZE) memcpy (A, X, sizeof (X[0)) * (size)) #define Memcopyall (A, X) memcpy (A, X, sizeof ( x) #define MAX (x, Y) (((x) > (y))? (x): (y)) #define min (x, y) (((x) < (y))?    (x): (y)) using namespace Std;const int M = 10000007;int f[m];void pri () {int t = 0;   for (int i = 2; I <= M; i++) {if (!f[i]) {f[i]++;        for (int j=2;i*j<=m;j++) {f[i*j]++;    }}//printf ("%d%d\n", f[i], i);    }}int Main () {//freopen ("Data.txt", "w", stdout);    PRI ();    int t,case1=1;            while (scanf ("%d", &t)!=eof) {while (t--) {int a,b,k,ans;            scanf ("%d%d%d", &a,&b,&k);            ans=0;            for (int i=a;i<=b;i++) {if (f[i]==k) ans++;        } printf ("Case #%d:%d\n", Case1++,ans); }} return 0;}`

Topic Final Test Data:

Facebook Hacker Cup Round 1 homework (test data included)

Related Keywords:

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

## A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

• #### Sales Support

1 on 1 presale consultation

• #### After-Sales Support

24/7 Technical Support 6 Free Tickets per Quarter Faster Response

• Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.