Topic Portal
1 /*2 Test Instructions: The problem is to find the number of factors b+1 to a and. 3 Mathematical +dp:a[i] Save the minimum factor of I, dp[i] = dp[i/a[i]] +1; another prefix and4 */5 /************************************************6 Author:running_time7 Created time:2015-8-1 14:08:348 File name:b.cpp9 *************************************************/Ten One#include <cstdio> A#include <algorithm> -#include <iostream> -#include <sstream> the#include <cstring> -#include <cmath> -#include <string> -#include <vector> +#include <queue> -#include <deque> +#include <stack> A#include <list> at#include <map> -#include <Set> -#include <bitset> -#include <cstdlib> -#include <ctime> - using namespacestd; in -typedefLong Longll; to Const intMAXN = 5e6 +Ten; + Const intINF =0x3f3f3f3f; - Const intMOD = 1e9 +7; the intCNT[MAXN]; * intA[MAXN]; $ BOOLIS_PRIME[MAXN];Panax Notoginseng intprime[maxn/Ten]; - ll DP[MAXN]; the ll SUM[MAXN]; + A voidSolvevoid) { thememset (Is_prime,true,sizeof(Is_prime)); + for(intI=2; i<=5000000; ++i) A[i] =i; - inttot =0; $ for(intI=2; i<=5000000; ++i) { $ if(Is_prime[i]) Prime[++tot] =i; - for(intj=1; J<=tot && i*prime[j]<=5000000; ++j) { - intTMP = i *Prime[j]; theIS_PRIME[TMP] =false; - if(A[tmp] > Prime[j]) a[tmp] =Prime[j];Wuyi if(i% prime[j] = =0) Break; the } - } Wudp[2] =1; - for(intI=3; i<=5000000; ++i) { AboutDp[i] = Dp[i/a[i]] +1; $ } - for(intI=2; i<=5000000; ++i) { -Sum[i] = sum[i-1] +Dp[i]; - } A } + the intMainvoid) {//codeforces Round #304 (Div. 2) D. Soldier and number Game - solve (); $ intT scanf ("%d", &T); the while(t--) { the intL, R; scanf ("%d%d", &r, &l); the if(L = =r) { thePuts ("0");Continue; - } inprintf ("%i64d\n", Sum[r]-sum[l]); the } the About return 0; the}
Math +DP codeforces Round #304 (Div. 2) D. Soldier and number Game