2 solutions

  • 0
    @ 2024-12-16 16:15:46
    #include <iostream>
    using namespace std;
    #define endl '\n'
    
    const int N = 1e5 + 5;
    int n, dp[N] = {1, 1, 2};
    signed main()
    {
      cin >> n;
      for (int i = 3; i <= n; i++)
        dp[i] = dp[i - 3] + i / 2 + 1;
      cout << dp[n];
      return 0;
    }
    
    • 0
      @ 2022-10-13 22:14:46
      #include <bits/stdc++.h>
      using namespace std;
      #define int long long
      #define x first
      #define y second
      #define LL long long
      typedef pair<int,int> PII;
      int dx[] = {-1, 1, 0, 0};
      int dy[] = {0, 0, -1, 1};
      const int N = 1e6 + 10, MOD = 1e9 + 10;
      int a[N], f[N];
      int n, m, res;
      
      
      void solve()
      {
          int n;
          cin >> n;
          f[0] = 1;
          for(int i = 1; i <= 3; i ++ )
          {
              for(int j = i; j <= n; j ++ )
                  f[j] += f[j-i];
          }
          cout << f[n];
      
      }
      signed main()
      {
          solve();
          return 0;
      }
      
      • 1

      Information

      ID
      1221
      Time
      1000ms
      Memory
      128MiB
      Difficulty
      6
      Tags
      # Submissions
      27
      Accepted
      12
      Uploaded By