QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#799008 | #7260. Ropes | rlc202204 | AC ✓ | 10ms | 4512kb | C++17 | 989b | 2024-12-04 20:26:13 | 2024-12-04 20:26:14 |
Judging History
answer
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 1e5 + 5;
const int mod = 1e9 + 7;
int fpow(int a, int b, int p) {
if (b == 0)
return 1;
int ans = fpow(a, b / 2, p);
ans = 1ll * ans * ans % p;
if (b % 2 == 1)
ans = 1ll * a * ans % p;
return ans;
}
int fac[N] = {0}, inv[N] = {0};
void init(int n) {
fac[0] = 1;
for (int i = 1; i <= n; i++)
fac[i] = 1ll * i * fac[i - 1] % mod;
inv[n] = fpow(fac[n], mod - 2, mod);
for (int i = n - 1; i >= 0; i--)
inv[i] = 1ll * (i + 1) * inv[i + 1] % mod;
}
int cmb(int n, int m) {
if (n < m)
return 0;
return 1ll * fac[n] * inv[m] % mod * inv[n - m] % mod;
}
int main() {
int n;
cin >> n;
init(n);
int ans = fac[n - 2];
int tot = 0;
for (int i = 1, x; i <= n; i++)
cin >> x, ans = 1ll * ans * inv[x - 1] % mod, tot += (x - 1);
if (tot != n - 2)
ans = 0;
cout << ans << endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3532kb
input:
9 1 3 2 1 3 1 2 1 2
output:
1260
result:
ok 1 number(s): "1260"
Test #2:
score: 0
Accepted
time: 1ms
memory: 3656kb
input:
9 1 2 1 1 3 2 1 3 2
output:
1260
result:
ok 1 number(s): "1260"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3712kb
input:
5 3 3 3 3 3
output:
0
result:
ok 1 number(s): "0"
Test #4:
score: 0
Accepted
time: 7ms
memory: 4304kb
input:
100000 3 2 1 3 3 1 3 2 3 3 3 2 1 1 3 2 1 3 1 2 3 2 2 2 3 1 2 3 2 3 3 3 2 2 2 1 3 3 3 3 2 2 3 2 1 1 2 1 3 1 3 1 3 3 1 3 2 3 3 2 1 1 2 2 3 3 3 2 2 1 2 2 3 2 3 3 2 1 3 2 2 3 2 1 2 1 3 2 2 3 1 3 2 3 2 1 2 3 3 2 3 1 2 2 1 3 1 2 1 2 3 3 1 1 3 2 3 1 3 3 3 3 3 2 3 3 2 3 1 2 2 2 1 3 3 2 2 2 1 3 1 1 1 1 2 3 2...
output:
0
result:
ok 1 number(s): "0"
Test #5:
score: 0
Accepted
time: 10ms
memory: 4312kb
input:
100000 1 1 1 1 1 1 1 2 2 3 1 1 3 1 2 1 2 1 2 1 1 1 1 1 1 1 2 2 2 2 1 1 3 1 1 1 3 3 3 1 1 1 2 1 1 2 1 1 2 1 1 1 2 1 1 1 1 1 2 2 3 1 1 1 1 1 1 1 1 1 1 1 1 1 3 1 1 1 2 1 3 1 2 1 2 2 1 3 3 1 1 2 2 1 1 2 1 1 2 1 1 2 1 1 1 1 2 1 2 1 3 1 3 2 2 3 2 1 1 1 3 1 2 1 1 1 1 1 2 3 3 3 1 1 1 1 1 1 2 1 1 1 1 2 1 1 1...
output:
0
result:
ok 1 number(s): "0"
Test #6:
score: 0
Accepted
time: 10ms
memory: 4428kb
input:
100000 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 3 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 2 1 1 1 2 1 1 1 2 1 1 1 3 1 1 1 1 1 2 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 3 1 1 1 1 1 2 1 1 2...
output:
0
result:
ok 1 number(s): "0"
Test #7:
score: 0
Accepted
time: 10ms
memory: 4500kb
input:
100000 2 3 1 2 3 2 2 2 2 2 2 2 1 3 2 2 2 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 2 1 3 2 2 3 2 1 2 2 2 2 3 2 2 1 2 2 2 2 2 2 2 3 1 2 1 3 1 2 2 2 1 2 3 1 2 2 3 2 3 2 2 2 2 2 3 3 2 2 1 3 2 2 2 2 2 3 2 2 2 1 1 3 2 3 2 2 1 3 1 2 3 2 3 2 2 2 2 2 2 2 2 2 1 2 1 3 2 2 2 3 2 2 2 2 3 1 3 3 2 2 2 1 2 3 2 2 2 3 3 1 2 2...
output:
0
result:
ok 1 number(s): "0"
Test #8:
score: 0
Accepted
time: 10ms
memory: 4488kb
input:
100000 2 2 3 3 3 1 1 2 1 2 3 1 3 1 1 2 3 1 3 1 3 1 2 2 1 2 3 1 3 2 2 1 3 3 3 1 2 3 3 3 2 3 3 2 2 3 1 3 3 3 1 2 3 3 1 1 3 3 2 2 1 2 2 3 1 3 2 3 1 3 1 3 1 3 1 1 3 3 3 3 2 3 3 2 1 1 1 2 1 3 1 3 1 2 2 2 3 3 3 2 3 1 3 2 3 3 3 3 2 2 1 1 2 2 3 2 2 1 2 3 1 3 3 1 1 3 1 3 3 2 1 3 3 2 2 3 3 2 2 1 1 1 2 3 3 1 3...
output:
0
result:
ok 1 number(s): "0"
Test #9:
score: 0
Accepted
time: 7ms
memory: 4432kb
input:
100000 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 2 1 2 1 1 1 2 2 1 1 1 2 2 1 1 1 1 2 1 1 2 1 1 1 1 2 1 1 1 1 1 2 1 2 1 1 1 2 1 3 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 2 3 1 1 1 2 1 1 1 1 1 1 2 1 1 1 1 1 2 2 1 1 1 1 1 1 1 1 1 3 1 2 1 1 1 1 1 2 1 1 1 1 1 1 2 2 2 1 1 1 2 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...
output:
0
result:
ok 1 number(s): "0"
Test #10:
score: 0
Accepted
time: 10ms
memory: 4432kb
input:
100000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 3 1 3 1 1 1 1 1 3 1 1 1 1 1 1 1 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1...
output:
0
result:
ok 1 number(s): "0"
Test #11:
score: 0
Accepted
time: 10ms
memory: 4452kb
input:
100000 2 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 3 3 3 2 1 1 1 1 1 1 1 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 3 1 1 1 1 1 2 2 1 2 1 1 1 1 1 1 1 1 1 3 1 1 2 3 1 1 1 1 1 1 1 3 2 1 1 1 1 3 1 2 3 1 3 1 1 1 1 1 1 1 1 2 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 3 1 1 1 1 1 1 1 1 1 1 1 1 3 1 1 1 1 1 1 1 3...
output:
0
result:
ok 1 number(s): "0"
Test #12:
score: 0
Accepted
time: 10ms
memory: 4436kb
input:
100000 3 1 1 1 1 1 1 1 1 1 1 3 1 3 3 1 3 1 3 1 1 3 3 3 1 3 1 3 3 1 3 3 3 1 3 3 1 1 1 1 1 3 1 1 1 1 1 1 3 3 2 3 3 3 1 3 1 3 1 3 3 1 3 3 1 1 1 3 1 2 3 1 3 1 1 1 3 1 3 1 1 1 3 1 1 1 1 1 1 3 1 1 1 1 3 1 3 1 3 1 1 3 1 3 3 1 3 1 1 1 3 3 1 1 2 3 3 1 3 3 2 3 3 1 3 3 1 1 1 1 1 1 3 3 1 1 1 1 1 1 1 1 3 1 3 1 1...
output:
0
result:
ok 1 number(s): "0"
Test #13:
score: 0
Accepted
time: 10ms
memory: 4432kb
input:
100000 1 3 1 1 1 1 3 1 1 2 1 1 1 3 2 1 3 1 3 3 2 2 3 2 2 2 3 1 3 3 3 1 1 1 3 2 2 2 1 1 2 3 1 1 1 1 1 1 3 2 2 1 3 2 1 1 1 1 1 1 1 3 1 2 1 2 3 1 1 1 3 3 2 1 1 2 2 2 2 1 1 1 1 1 1 3 3 1 1 1 1 1 1 2 1 2 3 2 2 1 1 3 1 1 1 1 2 2 2 1 1 1 1 3 2 1 1 1 3 3 1 1 1 2 1 3 1 2 3 1 1 2 1 2 1 1 1 2 1 1 1 1 2 1 1 3 2...
output:
0
result:
ok 1 number(s): "0"
Test #14:
score: 0
Accepted
time: 10ms
memory: 4388kb
input:
100000 2 1 1 1 1 3 3 1 1 1 1 1 3 3 1 2 3 1 2 1 1 3 1 3 2 3 2 3 1 1 2 2 1 1 1 1 2 2 2 2 3 3 3 1 3 1 1 1 1 2 3 1 3 1 1 1 3 2 3 1 1 2 3 2 2 1 1 1 1 2 2 1 3 3 1 3 1 2 3 2 3 1 1 3 3 3 2 3 3 1 2 1 1 3 1 3 2 3 1 1 2 1 1 3 3 1 1 3 1 3 1 1 3 3 3 2 1 3 1 1 3 3 2 2 3 3 3 1 1 2 3 1 1 1 2 3 2 3 3 1 3 2 3 3 3 3 1...
output:
919886418
result:
ok 1 number(s): "919886418"
Test #15:
score: 0
Accepted
time: 7ms
memory: 4312kb
input:
100000 2 2 2 2 1 2 3 2 2 2 2 3 3 1 2 2 2 2 2 2 3 2 2 2 3 2 2 1 2 2 2 3 2 2 2 2 2 2 2 3 3 1 2 2 3 2 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 1 1 3 2 3 2 2 2 1 2 2 1 2 1 3 2 2 1 1 2 1 1 1 2 2 2 3 2 2 2 2 2 2 3 2 2 2 2 2 2 1 3 1 2 1 2 1 2 2 3 3 2 3 2 2 3 2 2 3 2 3 2 2 3 2 3 2 3 2 2 2 2 1 2 1 2 2 3 2 1...
output:
148292810
result:
ok 1 number(s): "148292810"
Test #16:
score: 0
Accepted
time: 10ms
memory: 4288kb
input:
100000 2 1 3 3 2 2 1 2 2 2 2 2 2 2 2 1 1 2 2 1 2 1 3 3 1 2 2 1 3 2 3 2 1 2 1 2 2 1 1 2 1 3 2 3 1 2 3 2 1 1 1 3 3 2 1 1 3 3 3 2 1 3 2 3 3 1 2 1 3 2 3 2 2 2 1 1 2 2 1 2 2 2 2 2 1 3 3 1 2 2 2 3 2 3 3 2 2 3 2 2 1 2 3 2 3 2 3 2 1 2 3 1 2 2 2 1 2 1 3 3 2 2 2 2 3 2 3 1 2 2 2 2 2 2 3 2 1 3 3 3 3 2 2 2 2 3 2...
output:
450813336
result:
ok 1 number(s): "450813336"
Test #17:
score: 0
Accepted
time: 10ms
memory: 4488kb
input:
100000 2 2 2 3 3 2 2 2 2 2 2 2 2 2 2 2 2 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 2 2 2 2 2 2 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 2 2 2 2 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2...
output:
437199404
result:
ok 1 number(s): "437199404"
Test #18:
score: 0
Accepted
time: 7ms
memory: 4440kb
input:
100000 2 2 2 2 2 1 2 3 2 2 1 2 2 2 2 2 1 1 2 2 3 2 3 2 2 2 2 1 2 1 2 1 2 2 2 2 2 2 2 2 2 2 2 2 2 3 2 2 2 2 2 2 2 2 2 2 2 2 2 1 2 2 2 2 1 2 2 2 2 2 2 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 3 2 2 2 2 3 2 2 2 2 2 3 2 3 2 3 2 2 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 3 2 2 2...
output:
834463090
result:
ok 1 number(s): "834463090"
Test #19:
score: 0
Accepted
time: 10ms
memory: 4512kb
input:
100000 2 1 2 1 3 1 1 3 2 3 3 1 2 2 1 2 2 1 2 2 2 3 2 1 3 2 3 1 2 1 2 2 1 2 2 2 3 3 2 2 3 3 2 1 2 2 2 3 2 3 2 3 1 2 3 3 2 1 3 2 2 2 3 2 2 2 1 2 1 2 3 1 2 2 2 1 2 2 3 2 2 2 2 1 2 2 3 2 2 2 1 2 2 2 3 3 2 2 2 2 2 2 2 2 2 2 3 2 1 2 2 1 2 2 3 2 1 2 3 2 3 2 2 1 2 2 2 1 2 2 2 2 2 2 2 1 3 1 3 2 2 3 2 1 3 2 2...
output:
464088820
result:
ok 1 number(s): "464088820"
Test #20:
score: 0
Accepted
time: 10ms
memory: 4432kb
input:
100000 3 1 3 3 3 3 2 3 2 3 2 1 3 2 1 2 2 1 1 2 2 2 3 2 2 2 3 3 1 2 2 1 2 2 1 3 1 2 3 1 1 1 2 2 3 2 3 3 3 3 2 2 2 3 2 2 2 3 3 3 2 2 2 2 2 3 3 2 2 2 2 2 3 1 2 1 2 1 3 2 2 2 2 2 2 2 3 2 3 2 3 1 1 3 3 2 3 1 1 3 3 1 3 2 1 3 2 3 3 3 2 2 1 2 1 2 2 2 1 1 2 2 1 2 3 3 2 2 2 2 2 3 1 2 2 2 2 2 1 2 2 3 2 2 2 2 1...
output:
658273751
result:
ok 1 number(s): "658273751"
Test #21:
score: 0
Accepted
time: 10ms
memory: 4432kb
input:
100000 1 2 2 1 2 2 1 2 2 1 1 2 2 2 2 2 2 2 2 2 3 2 3 1 2 2 2 2 3 2 2 2 2 2 3 2 2 3 2 2 2 3 2 2 3 3 2 2 2 2 2 2 2 1 3 2 2 1 3 2 1 2 2 2 2 2 2 2 3 2 2 1 2 2 2 2 2 2 2 1 2 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 2 3 2 2 1 2 2 3 3 2 3 3 2 2 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 1 3 3 2 2 3 2 2 2 1 3 2 2 2 2 2 2 2 2...
output:
749020002
result:
ok 1 number(s): "749020002"
Test #22:
score: 0
Accepted
time: 7ms
memory: 4304kb
input:
100000 2 2 2 2 2 2 1 2 2 2 2 2 2 2 2 1 2 2 2 2 2 2 3 1 2 3 2 2 2 2 2 2 2 2 2 3 2 2 2 2 2 3 2 2 2 2 2 2 2 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 3 2 1 1 2 2 2 2 2 2 2 1 1 2 2 2 2 2 2 2 3 2 2 2 2 3 2 2 2 3 2 2 2 2 2 2 2 2 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 2 2 2 2 2 2 2 2 2 2 2 2 1...
output:
126071466
result:
ok 1 number(s): "126071466"
Test #23:
score: 0
Accepted
time: 10ms
memory: 4488kb
input:
100000 3 1 1 3 1 3 2 1 3 1 3 1 1 3 3 3 1 3 1 1 1 3 2 1 3 1 1 3 1 3 3 1 1 3 2 1 3 3 1 1 3 3 1 1 1 1 1 1 2 1 2 1 3 2 1 1 1 1 1 1 1 3 3 3 1 1 3 1 2 2 3 1 3 1 3 1 2 3 3 2 3 2 1 3 3 3 3 2 1 3 3 3 3 1 1 3 3 3 3 3 3 2 3 1 2 2 1 1 3 3 1 3 3 2 1 3 2 1 3 1 1 3 1 3 3 3 1 2 3 2 1 1 1 1 1 1 3 3 3 1 3 2 3 3 3 3 2...
output:
815045464
result:
ok 1 number(s): "815045464"
Test #24:
score: 0
Accepted
time: 1ms
memory: 3752kb
input:
1331 2 2 3 2 1 2 3 2 2 2 2 3 1 2 2 2 2 3 2 2 3 2 1 3 2 2 3 2 3 3 2 2 3 2 2 1 2 1 1 2 2 1 2 2 3 2 1 2 2 3 1 3 2 1 2 3 1 1 2 2 2 3 2 1 2 1 1 2 2 3 2 2 2 2 1 2 2 2 1 2 2 2 2 1 2 1 1 2 2 3 2 2 1 2 1 2 2 2 2 2 2 2 1 1 1 2 2 2 3 2 2 2 2 2 2 2 2 2 1 2 2 2 2 2 2 2 2 1 2 3 1 1 2 1 1 3 2 1 2 1 3 2 2 2 2 2 3 2...
output:
818233920
result:
ok 1 number(s): "818233920"
Test #25:
score: 0
Accepted
time: 1ms
memory: 3740kb
input:
385 1 1 2 2 2 1 2 3 3 1 1 2 2 3 2 1 3 2 2 2 3 2 3 2 1 3 3 1 2 2 3 3 3 1 2 3 2 3 1 2 2 3 2 3 3 1 1 3 2 1 1 3 3 1 2 3 1 1 2 1 1 1 2 3 1 3 2 2 2 2 1 3 1 2 2 1 1 1 3 2 3 3 1 1 3 2 2 3 2 1 1 3 1 3 3 1 3 3 2 3 3 3 1 2 2 3 3 2 3 2 3 2 1 1 3 2 2 2 3 3 1 2 1 3 1 3 3 2 2 3 3 3 1 1 3 3 1 3 2 3 2 1 3 1 2 1 1 3 ...
output:
467384285
result:
ok 1 number(s): "467384285"
Test #26:
score: 0
Accepted
time: 1ms
memory: 3556kb
input:
2065 3 1 1 3 3 3 2 1 2 2 1 3 3 1 2 1 2 1 2 3 1 1 3 2 3 1 3 3 3 3 3 3 3 1 1 1 1 2 3 3 2 3 3 3 1 3 3 1 1 3 3 2 1 3 3 3 2 2 3 3 1 1 3 3 2 3 1 3 3 3 2 3 1 3 2 1 3 1 3 1 3 1 3 1 3 3 1 2 1 1 3 3 1 3 1 3 3 3 1 3 3 1 1 3 3 3 3 2 3 2 3 3 3 3 1 3 3 1 3 3 3 1 3 2 2 3 3 3 3 1 3 1 1 2 1 1 3 3 3 1 3 1 1 2 3 1 1 3...
output:
188426891
result:
ok 1 number(s): "188426891"
Test #27:
score: 0
Accepted
time: 0ms
memory: 3652kb
input:
43 1 3 1 1 1 1 2 1 2 3 3 3 1 3 2 1 1 3 2 2 3 2 2 3 3 1 1 3 1 1 1 3 3 3 1 1 3 1 1 2 2 3 3
output:
657497820
result:
ok 1 number(s): "657497820"
Test #28:
score: 0
Accepted
time: 0ms
memory: 3588kb
input:
561 2 3 3 1 1 2 1 1 2 1 1 2 2 2 2 2 3 2 3 1 3 1 1 1 2 2 2 2 1 2 1 1 1 2 2 3 2 2 1 3 2 1 3 2 1 1 1 1 1 2 2 2 2 1 2 1 1 3 1 2 1 2 1 1 1 2 3 2 3 3 1 2 2 2 2 2 3 1 1 1 3 3 2 1 2 3 3 2 3 3 2 2 2 3 2 1 2 1 2 1 2 1 2 2 3 2 2 2 3 2 1 2 2 3 3 1 3 2 2 2 3 2 3 3 3 2 3 2 1 1 3 1 2 3 2 1 1 3 2 1 1 1 3 3 1 1 1 2 ...
output:
479845932
result:
ok 1 number(s): "479845932"
Test #29:
score: 0
Accepted
time: 0ms
memory: 3652kb
input:
2 1 2
output:
0
result:
ok 1 number(s): "0"
Test #30:
score: 0
Accepted
time: 0ms
memory: 3672kb
input:
7 1 1 3 3 1 1 2
output:
30
result:
ok 1 number(s): "30"
Test #31:
score: 0
Accepted
time: 0ms
memory: 3688kb
input:
130 2 1 2 2 3 2 2 1 2 1 2 3 3 2 2 1 1 3 3 1 2 1 2 3 2 1 2 2 3 1 2 1 2 3 2 1 2 2 2 2 2 1 1 3 3 1 2 1 2 2 2 2 1 2 3 1 1 3 2 3 1 3 3 3 1 1 2 1 2 1 3 3 2 2 2 1 1 2 3 1 2 1 2 1 2 2 2 2 2 3 3 3 2 2 3 3 2 3 1 3 2 3 2 1 1 1 1 2 3 2 2 1 2 1 2 3 1 2 2 2 3 2 3 2 3 3 2 2 2 3
output:
297870439
result:
ok 1 number(s): "297870439"
Test #32:
score: 0
Accepted
time: 1ms
memory: 3728kb
input:
8417 2 1 1 3 1 3 3 3 3 1 3 1 1 3 1 3 3 3 3 1 3 3 3 1 3 1 3 3 1 1 1 3 1 3 3 1 1 3 1 1 3 3 3 1 1 3 3 1 1 3 3 3 3 3 3 3 1 3 3 3 3 3 3 3 3 3 3 3 3 3 2 1 3 3 3 1 3 1 3 1 3 3 3 3 1 1 1 1 2 3 3 1 3 1 3 3 1 3 3 1 3 1 3 1 3 1 1 1 1 3 3 1 3 1 1 1 1 1 1 3 3 3 1 3 3 1 3 1 3 1 1 1 3 1 1 3 1 1 3 2 3 1 3 1 1 3 2 3...
output:
380707477
result:
ok 1 number(s): "380707477"
Test #33:
score: 0
Accepted
time: 1ms
memory: 3724kb
input:
6433 2 3 2 3 2 3 1 3 3 2 2 1 2 2 1 2 2 2 2 2 2 2 2 1 2 2 2 2 2 1 2 2 2 2 1 2 2 1 2 3 1 2 2 2 3 2 2 3 2 2 3 3 3 1 2 2 3 1 2 3 2 2 2 2 1 2 2 2 3 2 2 2 2 2 2 2 2 1 3 2 2 1 1 1 2 2 2 2 1 2 2 2 1 2 2 3 2 3 1 2 3 3 3 3 2 2 2 2 2 1 3 3 1 2 1 2 1 2 2 2 2 1 3 1 2 1 2 2 2 3 2 3 1 3 2 2 3 2 2 3 2 2 2 2 2 2 3 3...
output:
30227426
result:
ok 1 number(s): "30227426"
Test #34:
score: 0
Accepted
time: 10ms
memory: 4432kb
input:
100000 3 1 3 1 1 1 3 1 3 3 3 3 1 1 1 1 3 1 3 1 3 3 1 3 3 1 1 1 1 3 1 1 1 1 3 3 1 1 3 1 1 1 3 1 1 1 3 3 3 1 3 1 1 1 3 3 3 3 1 3 1 3 1 1 1 1 3 1 1 1 3 3 1 1 3 1 1 1 1 1 3 1 3 1 3 3 3 1 1 1 3 3 1 3 1 3 1 3 3 3 3 3 3 3 3 1 3 3 3 1 1 3 1 1 3 1 1 3 1 3 1 1 3 3 1 3 3 1 3 1 3 1 3 1 1 3 1 3 1 3 1 1 1 3 1 3 1...
output:
320555407
result:
ok 1 number(s): "320555407"
Test #35:
score: 0
Accepted
time: 10ms
memory: 4364kb
input:
100000 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2...
output:
248941163
result:
ok 1 number(s): "248941163"