QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#461655 | #1284. Partition Number | ZZZ | WA | 5ms | 5816kb | C++23 | 1.2kb | 2024-07-02 21:38:42 | 2024-07-02 21:38:43 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
void modadd(int &x, int v) {
x += v;
if (x >= mod) x -= mod;
}
void modsub(int &x, int v) {
x -= v;
if (x < 0) x += mod;
}
vector<int> partition_number(int n) {
vector<int> ans(n + 1), tmp(n + 1);
const int b = sqrt(n);
ans[0] = tmp[0] = 1;
for (int i = 1; i <= b; i++) {
for (int rep = 0; rep < 2; rep++) {
for (int j = i; j <= n - i * i; j++)
modadd(tmp[j], tmp[j - i]);
// for (int j = 0; j <= n; j++) printf("tmp[%d] = %d\n", j, tmp[j]);
}
if (i == 3) exit(0);
for (int j = i * i; j <= n; j++)
modadd(ans[j], tmp[j - i * i]);
}
return ans;
}
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
auto P = partition_number(300000);
int T;
cin >> T;
while (T--) {
int n, m;
cin >> n >> m;
vector<int> p(P.begin(), P.begin() + m + 1);
for (int it = 0; it < n; it++) {
int a;
cin >> a;
for (int j = m; j >= a; j--)
modsub(p[j], p[j - a]);
}
cout << p[m] << '\n';
}
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 5ms
memory: 5816kb
input:
5 1 4 1 1 4 2 1 4 3 3 4 1 2 3 4 4 1 2 3 4
output:
result:
wrong answer Unexpected EOF in the participants output