首页 > 代码库 > CF414BMashmokh and ACMDP

CF414BMashmokh and ACMDP

无脑搜,加个记忆化。当时只过了这题和A题

#include <cstdio>#include <cstring>#include <cmath>#include <algorithm>#include <climits>#include <string>#include <iostream>#include <map>#include <cstdlib>#include <list>#include <set>#include <queue>#include <stack>using namespace std;int n,k;int dp[2222][2222];const int mod= 1e9+7;int dfs(int x,int pre){    if(~dp[x][pre]) return dp[x][pre];    if(x==k) return dp[x][pre]=1;    int ret=0;    for(int i= 1;i*pre<=n;i++)        ret+=dfs(x+1,i*pre),ret%=mod;    return dp[x][pre]=ret;}int main(){    scanf("%d%d",&n,&k);    memset(dp,-1,sizeof(dp));    cout<<dfs(0,1)<<endl;    return 0;}