Title: Poke Me
Test instructions: Test instructions read the above a large string of English is actually very simple, is to give you a positive integer n, ask you n how many qualitative factors, but here n is given by a!/b!, that is, n= (a!/b!);
Analysis: Because here 1≤ b ≤ a ≤5 000 000, the data is very large, so simple violence must time out, specific look at the code.
1#include <iostream>2#include <cstdio>3 using namespacestd;4 Const intM = 5e6+5;5 6 intT; Number of test groups7 intNum[m] = {0}; Table, the number of the quality factor of n is stored in num[n]8 intSum[m] = {0}; Sum[i] (from num[1] to Num[i] and9 voidgetsum () {Tennum[1] =1; Onenum[2] =1; A for(intI=2; i<m; i++ ) { - if(Num[i] >1)//Determine if I is a prime number - Continue; theNum[i] =1; - for(intj=2; j*i<m; J + + ) { -Num[j*i] = Num[j] +1; - } + } - for(intI=1; i<m; i++ ) +Sum[i] = sum[i-1] +Num[i]; A } at - intMain () - { - getsum (); -scanf"%d", &t); - while(t-- ) { in intA, B; -scanf"%d%d", &a, &b); toprintf"%d\n", Sum[a]-sum[b]); + } -}
Codeforces 546D Soldier and number game table (count of quality factors)