酒鬼

#include <bits/stdc++.h>
using namespace std;
int main()
{int n;cin>>n;int a[10010];for(int i = 1;i<=n;i++){cin>>a[i];}int dp[1010][5] = {0};dp[0][0] = 0;dp[1][0] = 0;dp[1][1] = a[1];dp[1][2] = 0;dp[2][0] = a[1];dp[2][1] = a[2];dp[2][2] = a[1]+a[2];for(int i = 3;i<=n;i++){dp[i][0] = max(max(dp[i-1][0],dp[i-1][1]),dp[i-1][2]);dp[i][1] = dp[i-1][0]+a[i];dp[i][2] = dp[i-1][1]+a[i];}
// for(int i = 1;i<=n;i++)
// {
// for(int j = 0;j<=2;j++)
// {
// cout<<setw(3)<<dp[i][j];
// }
// cout<<endl;
// }cout<<max(max(dp[n][0],dp[n][1]),dp[n][2]);return 0;
}

#include <bits/stdc++.h>
using namespace std;
int main()
{int n;cin>>n;int m;cin>>m;int dp[1010][10] = {0};dp[0][0] = 1;dp[1][0] = 1;dp[1][1] = 1;for(int i = 2;i<=n;i++){for(int j = 0;j<m;j++){dp[i][0] += dp[i-1][j];}for(int j = 1;j<m;j++){dp[i][j] = dp[i-1][j-1];}}long long sum = 0;for(int i = 0;i<m;i++){sum += dp[n][i];}cout<<sum;return 0;
}

#include <bits/stdc++.h>
using namespace std;
int main()
{int n;cin>>n;int sh[10010];int z[10010];int y[10010];sh[1] = 1;z[1] = 1;y[1] = 1;for(int i = 2;i<=n;i++){sh[i] = (sh[i-1]+z[i-1]+y[i-1])%12345;z[i] = (z[i-1]+sh[i-1])%12345;y[i] = (y[i-1]+sh[i-1])%12345;}cout<<sh[n]+z[n]+y[n];return 0;
}