hihoCoder太阁最新面经算法竞赛13 register

Ended

Participants:132

Verdict:Accepted
Score:100 / 100
Submitted:2016-10-30 11:32:46

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
const int mo=1000000007;
int dp[110][200010];
int main()
{
    int n,k;
    dp[0][100000]=1;
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;++i) {
        int x;
        scanf("%d",&x);
        for(int j=200000;j>=x;--j) {
            dp[i][j]+=dp[i-1][j-x];
            dp[i][j]%=mo;
        }
        for(int j=200000-x;j>=0;--j) {
            dp[i][j]+=dp[i-1][j+x];
            dp[i][j]%=mo;
        }
    }
    printf("%d\n",dp[n][k+100000]);
    return 0;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX