#include<bits/stdc++.h> using namespace std; int dp[101],n,m,a[101]; int main(){ cin>>n>>m; dp[0]=1; for(int i=1;i<=n;i++) ci

沈泽宇  •  1年前


include<bits/stdc++.h>

using namespace std; int dp[101],n,m,a[101]; int main(){

cin>>n>>m;
dp[0]=1;
for(int i=1;i<=n;i++) cin>>a[i];
for(int i=1;i<=n;i++)
	for(int j=m;j>=1;j--)
		for(int k=1;k<=a[i]&&k<=j;k++)dp[j]=(dp[j]+dp[j-k])%1000007;
cout<<dp[m];
return 0;

}


评论:

/#include<bits/stdc++.h> using namespace std; const int N=10005,M=105,mod=20123; int st[N][M],x[N][M],n,m,k; int main(){

scanf("%d%d",&n,&m);
for(int i=0;i<n;i++)
for(int j=0;j<m;j++){
	scanf("%d%d",&st[i][j],&x[i][j]);
}
scanf("%d",&k);
int ans=0;
for(int i=0;i<n;i++){
	int t=x[i][k];
	ans=(ans+t)%mod;
	int s=0;
	for(int j=0;j<m;j++) s=s+st[i][j];
	t=t%s;
	if(t==0) t=s;
	for(int j=k;;j=(j+1)%m){
		if(st[i][j]){
			t--;
			if(t==0){
				k=j;
				break;
			}
		}
	}
}
printf("%d",ans);
return 0;

}


陈浩轩  •  1年前