QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#637279#7304. Coins 2liuziaoWA 453ms3960kbC++141.2kb2024-10-13 11:58:182024-10-13 11:58:18

Judging History

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

  • [2024-10-13 11:58:18]
  • 评测
  • 测评结果:WA
  • 用时:453ms
  • 内存:3960kb
  • [2024-10-13 11:58:18]
  • 提交

answer

#include <bits/stdc++.h>

// #define int int64_t

const int kMaxN = 105;

int n;
int a[kMaxN];

namespace Sub1 {
const int kMaxS = 3e5 + 5;

bool f[kMaxS];

void solve() {
  std::fill_n(f, kMaxS, 0);
  f[0] = 1;
  int d = 0;
  int64_t sum = 0;
  for (int i = 1; i <= n; ++i) {
    if (a[i]) d = std::__gcd(d, i);
    sum += 1ll * i * a[i];
  }
  if (!d) return void(std::cout << "1\n");
  for (int i = 1; i <= n; ++i) {
    static int lst[kMaxN];
    std::fill_n(lst, i, -1);
    for (int j = 0; j <= 3e5; ++j) {
      if (f[j]) lst[j % i] = j;
      if (lst[j % i] != -1 && (j - lst[j % i]) / i <= a[i]) f[j] = 1;
    }
  }
  int64_t ans = 0;
  for (int i = 0; i <= 3e5; ++i) ans += f[i];
  if (sum > 3e5) ans += sum / d - 3e5 / d;
  std::cout << ans << '\n';
}
} // namespace Sub1

void dickdreamer() {
  for (int i = 1; i <= n; ++i) std::cin >> a[i];
  Sub1::solve();
}

int32_t main() {
#ifdef ORZXKR
  freopen("in.txt", "r", stdin);
  freopen("out.txt", "w", stdout);
#endif
  std::ios::sync_with_stdio(0), std::cin.tie(0), std::cout.tie(0);
  int T = 1;
  // std::cin >> T;
  while (std::cin >> n) dickdreamer();
  // std::cerr << 1.0 * clock() / CLOCKS_PER_SEC << "s\n";
  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 6ms
memory: 3952kb

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: 9ms
memory: 3956kb

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: 0
Accepted
time: 453ms
memory: 3960kb

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
23781
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
17760
15926
250077
55576
4
104
282
45419
1687
2973
8
28482
6
4
2988
8
10
102
4
793
69
2
7624
4
181850
84
36589
3
2832
11
25
2
32457
127
33099
2
3
8
116
4
6
260
4
6
29027
4
2...

result:

ok 100 numbers

Test #4:

score: -100
Wrong Answer
time: 450ms
memory: 3880kb

input:

5
0 0 0 0 7282
5
1 0 1 1 1
5
0 100 1 6466 131627995
5
2 0 0 0 1
5
2 0 0 0 0
5
0 0 0 0 2
5
3 0 0 0 24
5
1 0 0 0 0
5
2 0 0 1033661 1
5
2 0 0 0 1
5
1 0 2 1 0
5
1 0 0 74999942 1
5
0 0 16 5 1
5
0 0 14 1 1
5
0 0 0 94148 2
5
1 0 0 0 0
5
0 4 66108 1 1
5
0 0 0 1 0
5
0 2 0 0 0
5
0 0 26609277 2057266 32110772
...

output:

7283
12
658166042
6
3
3
100
2
4134651
6
10
299924774
70
48
301600
2
198340
2
3
248610754
3064
6608764
27104219
88460
1225544
2128
206314
4247622
11710502
2
43189706
4
23417
1151
10
174058
1430769195
4852
2
2
10
77870413
6
13616298
6040751
1041238768
1854
400773738
1
4
6
31145402
935099
6
206782845
1...

result:

wrong answer 3rd numbers differ - expected: '658166041', found: '658166042'