Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
wa的代码,请指错?#include <iostream> #include <cstdio> #include <cstdlib> #include <cstring> #include <string> #include <algorithm> using namespace std; int main() { int n,m; int num[10005]; bool dp[100010][2]; while(scanf("%d %d",&n,&m)==2&&n) { memset(num,0,sizeof(num)); memset(dp,false,sizeof(dp)); for(int i=0;i<n;i++) { scanf("%d",&num[i]); } sort(num,num+n); int i,j; int ans = 0; for(i=0;i<n;i++) dp[num[i]][1] = true; for( i=1;i<n;i++) { for(j=m;j>num[i];j--) { if(dp[j-num[i]][0]) dp[j][1] = true; if(dp[j-num[i]][1]) dp[j][0] = true; } } for(i=1;i<=m;i++) { if(dp[i][1]&&(!dp[i][0]))ans++; } printf("%d\n",ans); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator