SHARE
TWEET

Untitled

a guest Jan 24th, 2019 88 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. using namespace std;
  3. int n, dp[100000];
  4. int main() {
  5.     cin >> n;
  6.     dp[0] = 1;
  7.     for (int i = 1; i <= n; i++) {
  8.         if (i % 2 == 0)
  9.             dp[i] += dp[i / 2];
  10.         if (i % 3 == 0)
  11.             dp[i] += dp[i / 3];
  12.         dp[i] += dp[i - 1];
  13.     }
  14.     cout << dp[n];
  15.     return 0;
  16. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top