ソースコード 拡げる

Copy
```// D.

#include <iostream>
#include <algorithm>
#include <sstream>
#include <cstdio>
#include <cstdlib>

using namespace std;

static const int MOD = 1000000007;

struct modll {
long long x;
modll() : x(0) { }
modll(long long _x) : x(_x) { }
operator int() const { return (int)x; }
modll operator+(const modll &r) { return (x + r.x) % MOD; }
modll operator+=(const modll &r) { return x = (x + r.x) % MOD; }
modll operator-(const modll &r) { return (x + MOD - r.x) % MOD; }
modll operator-=(const modll &r) { return x = (x + MOD - r.x) % MOD; }
modll operator*(const modll &r) { return (x * r.x) % MOD; }
modll operator*(int r) { return (x * r) % MOD; }
modll operator*=(const modll &r) { return x = (x * r.x) % MOD; }
modll inverse() {
modll r = 1, a = x;
for (int b = MOD - 2; b; b >>= 1) {
if (b & 1) {
r *= a;
}
a *= a;
}
return r;
}
};

int main(int argc, char *argv[]) {
int N, C;
cin >> N >> C;
modll dp[401][401];
dp[0][0] = 1;
for (int i = 0; i < N; ++i) {
int a;
cin >> a;
modll x(1);
for (int j = 0; j <= C; ++j) {
for (int k = 0; j + k <= C; ++k) {
dp[i + 1][j + k] += dp[i][k] * x;
}
x *= a;
}
}
cout << dp[N][C] << endl;
return 0;
}
```

#### 提出情報

提出日時 2016-08-13 21:53:09+0900 E - キャンディーとN人の子供 hotpepsi C++14 (GCC 5.4.1) 400 1267 Byte WA 240 ms 1536 KB

#### ジャッジ結果

セット名 Sample Subtask All

 AC × 2 WA × 3
 AC × 12
 AC × 14 WA × 16
セット名 テストケース
Sample 0_000.txt, 0_001.txt, 0_002.txt, 0_003.txt, 0_004.txt
Subtask 0_001, 0_003, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt, 1_010.txt, 1_011.txt, 1_012.txt, 1_013.txt, 1_014.txt, 1_015.txt, 1_016.txt
All 0_000.txt, 0_001.txt, 0_002.txt, 0_003.txt, 0_004.txt, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt, 1_010.txt, 1_011.txt, 1_012.txt, 1_013.txt, 1_014.txt, 1_015.txt, 1_016.txt, 2_017.txt, 2_018.txt, 2_019.txt, 2_020.txt, 2_021.txt, 2_022.txt, 2_023.txt, 2_024.txt, 2_025.txt, 2_026.txt, 2_027.txt, 2_028.txt, 2_029.txt
ケース名 結果 実行時間 メモリ
0_000.txt WA 6 ms 1536 KB
0_001.txt AC 6 ms 1536 KB
0_002.txt WA 6 ms 1536 KB
0_003.txt AC 6 ms 1536 KB
0_004.txt WA 7 ms 1536 KB
1_005.txt AC 6 ms 1536 KB
1_006.txt AC 7 ms 1536 KB
1_007.txt AC 7 ms 1536 KB
1_008.txt AC 7 ms 1536 KB
1_009.txt AC 7 ms 1536 KB
1_010.txt AC 7 ms 1536 KB
1_011.txt AC 7 ms 1536 KB
1_012.txt AC 7 ms 1536 KB
1_013.txt AC 7 ms 1536 KB
1_014.txt AC 239 ms 1536 KB
1_015.txt AC 239 ms 1536 KB
1_016.txt AC 238 ms 1536 KB
2_017.txt WA 6 ms 1536 KB
2_018.txt WA 6 ms 1536 KB
2_019.txt WA 7 ms 1536 KB
2_020.txt WA 7 ms 1536 KB
2_021.txt WA 7 ms 1536 KB
2_022.txt WA 7 ms 1536 KB
2_023.txt WA 240 ms 1536 KB
2_024.txt WA 238 ms 1536 KB
2_025.txt WA 45 ms 1536 KB
2_026.txt WA 7 ms 1536 KB
2_027.txt WA 192 ms 1536 KB
2_028.txt WA 9 ms 1536 KB
2_029.txt WA 8 ms 1536 KB