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 |
5.5秒险过,哈哈哈哈哈哈哈哈哈#include<cstdio> #include<cstring> #include<algorithm> using namespace std; int N, S; int dp[100000][2]; int arr[10000]; int main() { while(true) { scanf("%d %d", &N, &S); if(N == 0 && S == 0) { break; } for(int i = 0; i < N; i ++) { scanf("%d", arr + i); } memset(dp, 0, sizeof(dp)); dp[0][0] = true; int ans = 0; for(int j = 0; j < N; j ++) { for(int i = S; i >= 0; i --) { if(arr[j] <= i) { if(dp[i - arr[j]][0]) { dp[i][1] = true; } if(dp[i - arr[j]][1]) { dp[i][0] = true; } } } } for(int i = 1; i <= S; i ++) { if(!dp[i][0] && dp[i][1]) { ans ++; } } printf("%d\n", ans); } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator