QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#440709#7260. RopesI_Love_Sonechka#AC ✓11ms3856kbC++171.4kb2024-06-13 23:13:512024-06-13 23:13:51

Judging History

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

  • [2024-06-13 23:13:51]
  • 评测
  • 测评结果:AC
  • 用时:11ms
  • 内存:3856kb
  • [2024-06-13 23:13:51]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

// c++ short types
#define vt vector
//typedef long long ll;
typedef long double ld;

void whattime() { cout << "finished in " << clock() * 1.0 / CLOCKS_PER_SEC << " sec" << endl; }
const int inf = 1e9;
const int mod = 1e9+7;
bool debug = false;
const ld eps = 1e-9;

mt19937_64 rng((unsigned int) chrono::steady_clock::now().time_since_epoch().count());

void add(int &a, int b) {
	a += b;
	if(a >= mod) {
		a -= mod;
	}
	if(a < 0) {
		a += mod;
	}
}
int mul(int a, int b) {
	return a * 1ll * b % mod;
}
int bin_pow(int b, int p) {
	int r = 1;
	for(;p;p>>=1,b=mul(b,b)) {
		if(p&1) {
			r = mul(r, b);
		}
	}
	return r;
}
int inv(int x) {
	return bin_pow(x, mod-2);
}

void solve() {
	int n; cin >> n;
	vt<int> d(n);
	for(int i = 0; i < n; ++i) {
		cin >> d[i];
	}
	int fact = 1;
	for(int i = 1; i <= n-2; ++i) {
		fact = mul(fact, i);
	}
	int cnt = 0;
	for(int i = 0; i < n; ++i) {
		cnt += d[i];
	}
	if(cnt != 2 * n -2) {
		cout << 0 << "\n";
		return ;
	}
	for(int i = 0; i < n; ++i) {
		if(d[i] == 3) {
			fact = mul(fact, inv(2));
		}
	}
	cout << fact << '\n';
}

int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	int tt = 1;
	if(debug) {
		tt = 1e5;
	} else {
//		cin >> tt;
	}
	for(int t = 0; t < tt; ++t) {
		solve();
	}
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3680kb

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: 3588kb

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: 1ms
memory: 3648kb

input:

5
3
3
3
3
3

output:

0

result:

ok 1 number(s): "0"

Test #4:

score: 0
Accepted
time: 4ms
memory: 3856kb

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: 4ms
memory: 3632kb

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: 4ms
memory: 3696kb

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: 2ms
memory: 3644kb

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: 4ms
memory: 3660kb

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: 2ms
memory: 3652kb

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: 4ms
memory: 3608kb

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: 4ms
memory: 3664kb

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: 2ms
memory: 3816kb

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: 4ms
memory: 3692kb

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: 6ms
memory: 3668kb

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: 3ms
memory: 3704kb

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: 5ms
memory: 3632kb

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: 4ms
memory: 3780kb

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: 2ms
memory: 3660kb

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

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: 5ms
memory: 3628kb

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: 3ms
memory: 3656kb

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: 5ms
memory: 3632kb

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: 3704kb

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: 0ms
memory: 3620kb

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: 3616kb

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: 0ms
memory: 3620kb

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: 1ms
memory: 3612kb

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: 1ms
memory: 3552kb

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: 1ms
memory: 3592kb

input:

2
1
2

output:

0

result:

ok 1 number(s): "0"

Test #30:

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

input:

7
1
1
3
3
1
1
2

output:

30

result:

ok 1 number(s): "30"

Test #31:

score: 0
Accepted
time: 1ms
memory: 3620kb

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: 3648kb

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: 0ms
memory: 3676kb

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: 11ms
memory: 3812kb

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: 4ms
memory: 3856kb

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"