Types of vegetarian factors:
For an n, what is his total number of elements? Facebook Hackercup Round1 Homework question, 10pts
Use Sieve method, then p[j]=i->p[j]++
int getprimefactortypetimes (int n) { memset (p, 0, sizeof p); for (int i=2;2*i<=n;i++) { if (! P[i]) {for (int j=2*i;j<=n;j+=i) p[j]++; } } return p[n];}
Types of vegetarian factors:
For a n, what is the total number of his factors? Codeforces Http://codeforces.com/contest/546/problem/D
The first sieve method to calculate a factor of each j, as long as any one on the line, and then DP, using the idea of divided treatment, solve the sub-problem, and then push it up just fine
LL DP[MAXN], P[MAXN], SUM[MAXN], N, T, M, A, b;void Init () { memset (p, 0, sizeof p); P[1]=1; for (LL i=2;i*i<=maxn;i++) { if (! P[i]) {for (LL j=i*i;j<=maxn;j+=i) p[j]=i; } } Dp[1]=dp[2]=dp[3]=1;for (LL i=2;i<=maxn;i++) dp[i]= (P[i]? (dp[i/p[i]]+1): 1); Sum[0]=0;for (LL i=1;i<=maxn;i++) sum[i]=sum[i-1]+dp[i];} int main () {/* #ifndef Online_judge freopen ("In.txt", "R", stdin); Freopen ("OUT.txt", "w", stdout); #endif */ Init (); T=getint (); for (int ti=1;ti<=t;ti++) { a=getint (), B=getint ();p rintf ("%d\n", Sum[a]-sum[b]); } return 0;}
What is the number of calculation factors?
Brute force enumeration, decomposition from 1->SQRT (n), or mass factor, and then each power +1 multiplicative.
File end flag Eof,windows Ctrl + Z is the end, Linux is just-1, which represents a return value of the function
The problem of the number of factors of a factor