QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#461655#1284. Partition NumberZZZWA 5ms5816kbC++231.2kb2024-07-02 21:38:422024-07-02 21:38:43

Judging History

你现在查看的是最新测评结果

  • [2024-07-02 21:38:43]
  • 评测
  • 测评结果:WA
  • 用时:5ms
  • 内存:5816kb
  • [2024-07-02 21:38:42]
  • 提交

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