QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#626544#7304. Coins 2ucup-team4906#WA 0ms3684kbC++201.4kb2024-10-10 10:11:142024-10-10 10:11:15

Judging History

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

  • [2024-10-10 10:11:15]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3684kb
  • [2024-10-10 10:11:14]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;

#define N 21
int n;
int a[N];
const int M = 400;
bitset<M + 1>B;

void sol()
{
    for (int i = 1; i <= n; i ++) cin >> a[i];
    ll sum = 0, t = 0;
    for (int i = 1; i <= n; i ++) 
    {
        sum += 1LL * a[i] * i;
        if (a[i]) t = gcd(t, i);
    } 
    if (t == 0) {cout << 1 << '\n'; return ;}
    ll ans = sum / t + 1;
    B = 0; B[0] = 1;
    for (int i = 1; i <= n; i ++)
    {
        int t = i, v = a[i];
        // cout << "GG:" << i << endl;
        while (true)
        {
            if (v == 0 || t > M) break;
            B = B | (B << t);
            // cout << "EE:" << t << endl;
            v --; 
            if (v & 1) {B = B | (B << t); }
            t <<= 1; v /= 2;
        }
    }
    if (sum <= M)
    {
        for (int i = 1; i <= sum; i ++) if (i % t == 0 && !B[i])ans --;
    }
    else if (sum <= 2 * M)
    {
        for (int i = 1; i <= sum; i ++) if (i % t == 0)
        {
            if (i <= M) {if (!B[i])ans --;}
            else {if (!B[sum - i])ans --;}  
        }
    }
    else
    {
        for (int i = 1; i <= M; i ++) if (i % t == 0 && B[i] == 0)ans -= 2;
    }
    cout << ans << '\n';
}

int main()
{
    ios::sync_with_stdio(0); cin.tie(0);
    int T = 1;
    while (cin >> n) sol();
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3684kb

input:

3
0 1 2
3
0 2 3

output:

6
12

result:

ok 2 number(s): "6 12"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3572kb

input:

1
0
15
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000

output:

1
120000000001

result:

ok 2 number(s): "1 120000000001"

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 3580kb

input:

5
0 2 1 0 0
5
0 0 0 0 53
5
0 6 3 0 0
5
1 0 0 0 1
5
1 0 0 0 0
5
2 0 0 0 116
5
2 0 0 0 0
5
1 0 1 106 1356
5
0 2 0 0 7926
5
0 0 2 1 2004
5
1 0 0 0 1
5
0 0 0 1 5
5
0 0 0 0 0
5
0 1 32840 0 1
5
2 0 0 0 12
5
2 0 0 1 1
5
0 1 79 56770 10
5
1 0 0 1 0
5
0 1 1 2 52165
5
0 0 0 0 1
5
0 0 1 13 0
5
0 0 0 1 10
5
0 0...

output:

6
54
20
4
2
351
3
7207
39315
10027
4
12
1
98524
39
10
227368
4
260837
2
28
22
114
78
76
4
280
233
8
1
12
214572
10
2
1
1
2
108
22039
19747
250077
55576
4
104
282
45419
1687
4633
8
28482
6
4
4658
8
10
102
4
793
69
2
18578
4
242267
84
36589
3
6597
11
25
2
32457
127
33099
2
3
8
116
4
6
260
4
6
29027
4
...

result:

wrong answer 9th numbers differ - expected: '23781', found: '39315'