//バグ:main関数にint n; を宣言していた(ので、グローバル変数のnは0であった) #include #define int long long using namespace std; int n; int dp[9][601]; int f(int id, int diff) { if (diff < 0) return 0; if (id == 8) return (diff == 0); if (dp[id][diff] != -1) return dp[id][diff]; int ans = 0; for (int value = 0; value <= n; value++) { ans += f(id + 1, diff - value); } return (dp[id][diff] = ans); } signed main() { cin >> n; for (int i = 0; i < 9; i++) for (int j = 0; j <= 6 * n; j++) dp[i][j] = -1; cout << f(0, 6 * n) << endl; return 0; }