Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- #include <vector>
- #include <queue>
- #include <cmath>
- using namespace std;
- int n, k;
- int memo[1000][1000];
- vector<int> v [1000];
- int dp(int n_1, int predhoden){
- if(n_1 == n){
- return 1;
- }
- if(memo[n_1][predhoden] != -1){
- return memo[n_1][predhoden];
- }
- int mod = 1e9 + 7;
- int res = 0;
- for (int i = 0; i < v[predhoden].size(); i++) {
- if(predhoden != v[predhoden][i] ){
- res += dp(n_1 +1, v[predhoden][i] );
- res = res% mod;
- }
- }
- return memo[n_1][predhoden] = res;
- }
- int main(){
- cin >> n >> k;
- int res = 0;
- for (int i = 0; i < 1000; i++) {
- for (int j = 0; j < 1000; j++) {
- memo[i][j]= -1;
- }
- }
- for (int i = 1; i <= k; i++) {
- for (int j = 1; j <= k; j++) {
- if(i%j == 0 || j%i == 0){
- v[i].push_back(j);
- }
- }
- }
- int mod = 1e9 + 7;
- for (int i = 1; i <= k; i++) {
- res += dp(1,i);
- res %= mod;
- }
- cout << res << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement