第五题可ac: ``` #include<iostream> (5488)#include<unordered_map> #include<map> (5868)#include<vector> using namespace std; #define BOUND 998244353 struct Solution{ vector<vector<int>> mem; int MAX, m, rs; int dfs(int pos,int base){ if(mem[pos][base]!=-1){ return mem[pos][base]; } mem[pos][base] = 0; int i = 1; if(pos==1){ int count = MAX / base; mem[pos][base] += count; mem[pos][base] %= BOUND; return mem[pos][base]; } while(base*i<=MAX){ mem[pos][base]+=dfs( pos - 1, base * i); mem[pos][base] %= BOUND; i++; } return mem[pos][base]; } Solution(int MAX,int m,int rs):MAX(MAX),m(m),rs(rs){ mem = vector<vector<int>>(m + 1, vector<int>(MAX + 1, -1)); } }; int main(){ int n, m; cin >> n>>m; Solution s(n, m, 0); cout << s.dfs(m, 1); } ```
1 2

相关推荐

点赞 评论 收藏
分享
牛客网
牛客企业服务