怎么肥四,哪里有问题吗,用的不太熟,所以写的二维的
查看原帖
怎么肥四,哪里有问题吗,用的不太熟,所以写的二维的
1180146
kaito_936楼主2024/4/13 16:09

#include<iostream>
using namespace std;
using ll = long long;
ll dp[101][101], n, m;
int temp;

int main()
{
    cin >> n >> m;
    dp[0][0] = 1;
    for (int i = 1; i <= n; i++) {
	cin >> temp;
	for (int j = 1; j <= m; j++) {
	    for (int t = 0; t <= temp&&t<=j; t++) {
		dp[i][j] += dp[i - 1][j - t];
	    }
	}
    }
    cout << dp[n][m]%1000007 << endl;
    return 0;
}
2024/4/13 16:09
加载中...