Topic Links:
Codeforces 414B
Main topic:
Defines a sequence in which the previous item is divisible to the next, given the range of values in the sequence and the length of the sequence, and how many constructs are asked.
Topic Analysis:
- We define the state Dp[i][j] as the number of scenarios in which the previous I term has been determined and item I is J.
- Transfer equation d P[I][J]= ∑ k| J d P[I?1][k]
- Complexity of O ( n k )
AC Code:
#include <iostream>#include <cstring>#include <algorithm>#include <cstdio>#define MAXusing namespace STD;typedef Long LongLL;intN,k;ConstLL mod=1e9+7; LL Dp[max][max];intMain () { while( ~scanf("%d%d", &n, &k)) {memset(DP,0,sizeof(DP)); for(inti =1; I <= N; i++) dp[1][i] =1; for(inti =2; I <= K; i++) for(intj =1; J <= N; J + +) for(intK =1; K*k<=j; k++) {if(j%k)Continue; DP[I][J] + = dp[i-1][K]; DP[I][J]%= mod;intx = j/k;if(x = = k)Continue; DP[I][J] + = dp[i-1][X]; DP[I][J]%= mod; }intAns =0; for(inti =1; I <= N; i++) {ans + = dp[k][i]; Ans%= MoD; }printf("%d\n", ans); }}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Codeforces 414B B. Mashmokh and ACM (DP)