提交记录 47671


用户 题目 状态 得分 用时 内存 语言 代码长度
jiegec noip18b. 【NOIP2018】货币系统 Accepted 100 552.34 us 28 KB C 2.07 KB
提交时间 评测时间
2026-09-13 01:11:09 2026-09-13 01:11:13
// This code is AI-generated. (AI 生成的代码)
// NOIP2018 货币系统: sort denominations; a denomination is redundant iff it is
// representable by the already kept (smaller) ones.  Mark reachable sums with a
// complete-knapsack update whenever a denomination is kept.
#include <stdio.h>
#include <string.h>
static int a[105];
static char can[25005];
static char buf[1 << 16], ob[1 << 10];
static char *gp;
int main() {
    int len = (int)fread(buf, 1, sizeof(buf) - 1, stdin);
    buf[len] = 0; gp = buf;
    char *op = ob;
#define RD(dst) do { while (*gp < '0') gp++; int v = 0; while (*gp >= '0' && *gp <= '9') v = v * 10 + (*gp++ - '0'); dst = v; } while (0)
    int T; RD(T);
    while (T--) {
        int n; RD(n);
        int mx = 0;
        for (int i = 0; i < n; i++) { RD(a[i]); if (a[i] > mx) mx = a[i]; }
        for (int i = 1; i < n; i++) {
            int x = a[i], j = i - 1;
            while (j >= 0 && a[j] > x) { a[j + 1] = a[j]; j--; }
            a[j + 1] = x;
        }
        enum { W = 400 };
        static unsigned long long bs[W];
        int nw = (mx >> 6) + 1;
        for (int j = 0; j < nw; j++) bs[j] = 0;
        bs[0] = 1;
        int ans = 0;
        for (int i = 0; i < n; i++) {
            int v = a[i];
            if ((bs[v >> 6] >> (v & 63)) & 1) continue;
            ans++;
            for (int sh = v; sh <= mx; sh <<= 1) {
                int ws = sh >> 6, b = sh & 63;
                if (ws >= nw) break;
                if (b == 0) {
                    for (int j = nw - 1; j >= ws; j--) bs[j] |= bs[j - ws];
                } else {
                    for (int j = nw - 1; j >= ws; j--) {
                        unsigned long long x = bs[j - ws] << b;
                        if (j - ws - 1 >= 0) x |= bs[j - ws - 1] >> (64 - b);
                        bs[j] |= x;
                    }
                }
            }
        }
        char t[8]; int k = 0;
        if (!ans) t[k++] = '0';
        while (ans) { t[k++] = (char)('0' + ans % 10); ans /= 10; }
        while (k) *op++ = t[--k];
        *op++ = '\n';
    }
    fwrite(ob, 1, op - ob, stdout);
    return 0;
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #19.82 us20 KBAcceptedScore: 5

Testcase #28.1 us20 KBAcceptedScore: 5

Testcase #38.23 us20 KBAcceptedScore: 5

Testcase #49.29 us20 KBAcceptedScore: 5

Testcase #58.89 us20 KBAcceptedScore: 5

Testcase #68.59 us20 KBAcceptedScore: 5

Testcase #79.9 us20 KBAcceptedScore: 5

Testcase #89.55 us20 KBAcceptedScore: 5

Testcase #910.11 us20 KBAcceptedScore: 5

Testcase #1011.07 us20 KBAcceptedScore: 5

Testcase #1111.07 us20 KBAcceptedScore: 5

Testcase #1210.46 us20 KBAcceptedScore: 5

Testcase #1310.12 us20 KBAcceptedScore: 5

Testcase #1414.79 us20 KBAcceptedScore: 5

Testcase #1513.38 us20 KBAcceptedScore: 5

Testcase #1614.23 us20 KBAcceptedScore: 5

Testcase #17529.25 us28 KBAcceptedScore: 5

Testcase #18536.93 us28 KBAcceptedScore: 5

Testcase #19543.83 us28 KBAcceptedScore: 5

Testcase #20552.34 us28 KBAcceptedScore: 5


Judge Duck Online | 评测鸭在线
Server Time: 2026-09-24 18:06:11 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠