QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#13579#1882. Drunkards123456AC ✓237ms204496kbC++201.9kb2021-09-18 16:43:222022-05-17 02:51:19

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-05-17 02:51:19]
  • 评测
  • 测评结果:AC
  • 用时:237ms
  • 内存:204496kb
  • [2021-09-18 16:43:22]
  • 提交

answer

#include <bits/stdc++.h>

const int N = 5050;
const int mod = 998244353;

inline int inc(int x, int y) { x += y - mod; return x + (x >> 31 & mod); }
inline int dec(int x, int y) { x -= y; return x + (x >> 31 & mod); } 
inline int mul(int x, int y) { return 1ll * x * y % mod; }

inline void upd(int &x, int y) { x = inc(x, y); }
inline void pud(int &x, int y) { x = mul(x, y); }  

int a[N], f[N][N << 1], n, p, q;
#define g(i, j) f[i][j + 5001]

inline int fastpow(int x, int p)
{
	int r = 1;
	while (p)
	{
		if (p & 1) pud(r, x);
		pud(x, x);
		p >>= 1;
	}
	return r;
}

template <int T>
struct fast_io
{
	char p[T], q[T], * p1, * p2, * q1, * q2;
	fast_io()
	{
		p1 = p2 = p;
		q1 = q, q2 = q + T;
	}
	inline char gc()
	{
		return p1 == p2 && (p2 = (p1 = p) + fread(p, 1, T, stdin), p1 == p2) ? EOF : *p1++;
	}
	inline void pc(char c)
	{
		if (q1 == q2) q2 = (q1 = q) + fwrite(q, 1, T, stdout);
		*q1++ = c;
	}
	~fast_io()
	{
		fwrite(q, 1, q1 - q, stdout);
	}
};
fast_io<1 << 20> io;
inline int read()
{
	int res = 0, neg = 1;
	char ch;
	do 
	{
		ch = io.gc();
		if (ch == '-') neg = -1;
	} while (ch < 48 || ch > 57);
	do res = res * 10 + ch - 48, ch = io.gc(); while (ch >= 48 && ch <= 57);
	return res * neg;
}

inline void put(int64_t x)
{
	if (x < 0) io.pc('-'), x = -x;
	if (x >= 10) put(x / 10);
	io.pc(48 + x % 10);
}
inline void output(int64_t x, char ch = ' ')
{
	put(x);
	io.pc(ch);
}


int main()
{
	n = read(), p = mul(read(), fastpow(100, mod - 2));
	q = dec(1, p);
	for (int i = 1; i <= n; ++i) a[i] = read();
	g(n, 0) = 1;
	for (int k = n - 1; k >= 0; --k)
		for (int i = -n; i <= n; ++i)
			if (i) g(k, i) = inc(mul(g(k + 1, i), p), mul(g(k + 1, i - a[k + 1]), q));
			else g(k, i) = 1;
	int ans = 0;
	for (int i = -n; i <= n; ++i)
		upd(ans, g(0, i));
	pud(ans, fastpow(n + n + 1, mod - 2));
	printf("%d", ans);
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 3ms
memory: 5720kb

input:

2 28
1 1

output:

702764025

result:

ok 1 number(s): "702764025"

Test #2:

score: 0
Accepted
time: 3ms
memory: 5840kb

input:

5 50
-1 1 -1 -1 -1

output:

17015529

result:

ok 1 number(s): "17015529"

Test #3:

score: 0
Accepted
time: 3ms
memory: 5768kb

input:

5 50
-1 1 -1 1 1

output:

680621150

result:

ok 1 number(s): "680621150"

Test #4:

score: 0
Accepted
time: 2ms
memory: 5720kb

input:

10 50
1 1 1 1 1 -1 -1 -1 1 1

output:

812744705

result:

ok 1 number(s): "812744705"

Test #5:

score: 0
Accepted
time: 2ms
memory: 5708kb

input:

10 50
-1 -1 1 1 -1 -1 1 -1 -1 -1

output:

158575275

result:

ok 1 number(s): "158575275"

Test #6:

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

input:

15 65
1 -1 -1 -1 1 -1 -1 -1 1 -1 1 1 -1 -1 1

output:

553313087

result:

ok 1 number(s): "553313087"

Test #7:

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

input:

15 65
-1 -1 1 -1 -1 -1 1 1 -1 1 -1 -1 1 -1 -1

output:

140408188

result:

ok 1 number(s): "140408188"

Test #8:

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

input:

10 7
1 1 1 1 1 1 1 1 1 1

output:

375530019

result:

ok 1 number(s): "375530019"

Test #9:

score: 0
Accepted
time: 3ms
memory: 5708kb

input:

10 73
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1

output:

289966217

result:

ok 1 number(s): "289966217"

Test #10:

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

input:

10 0
1 1 -1 1 1 1 -1 1 -1 1

output:

95070891

result:

ok 1 number(s): "95070891"

Test #11:

score: 0
Accepted
time: 3ms
memory: 7808kb

input:

10 0
1 1 1 -1 1 1 1 1 1 1

output:

570425345

result:

ok 1 number(s): "570425345"

Test #12:

score: 0
Accepted
time: 3ms
memory: 5768kb

input:

10 0
-1 1 1 1 -1 1 -1 -1 1 1

output:

475354454

result:

ok 1 number(s): "475354454"

Test #13:

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

input:

10 0
-1 -1 -1 -1 -1 -1 1 -1 1 -1

output:

332748118

result:

ok 1 number(s): "332748118"

Test #14:

score: 0
Accepted
time: 3ms
memory: 5672kb

input:

10 0
1 1 1 1 1 1 -1 1 1 1

output:

570425345

result:

ok 1 number(s): "570425345"

Test #15:

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

input:

10 0
-1 -1 -1 1 1 1 -1 1 -1 1

output:

475354454

result:

ok 1 number(s): "475354454"

Test #16:

score: 0
Accepted
time: 3ms
memory: 7756kb

input:

10 0
-1 1 1 1 1 -1 -1 1 -1 1

output:

95070891

result:

ok 1 number(s): "95070891"

Test #17:

score: 0
Accepted
time: 3ms
memory: 5784kb

input:

10 100
-1 1 -1 1 1 -1 -1 -1 -1 -1

output:

617960790

result:

ok 1 number(s): "617960790"

Test #18:

score: 0
Accepted
time: 3ms
memory: 5632kb

input:

10 100
1 1 1 1 1 1 -1 1 1 1

output:

617960790

result:

ok 1 number(s): "617960790"

Test #19:

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

input:

10 100
-1 -1 -1 -1 1 1 -1 -1 1 1

output:

617960790

result:

ok 1 number(s): "617960790"

Test #20:

score: 0
Accepted
time: 2ms
memory: 7768kb

input:

10 27
1 -1 -1 1 -1 -1 1 -1 -1 1

output:

89502877

result:

ok 1 number(s): "89502877"

Test #21:

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

input:

10 27
1 1 -1 1 -1 1 1 -1 -1 1

output:

602378374

result:

ok 1 number(s): "602378374"

Test #22:

score: 0
Accepted
time: 218ms
memory: 202336kb

input:

5000 25
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 -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 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 ...

output:

961556565

result:

ok 1 number(s): "961556565"

Test #23:

score: 0
Accepted
time: 211ms
memory: 202384kb

input:

5000 25
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 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 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 ...

output:

234465387

result:

ok 1 number(s): "234465387"

Test #24:

score: 0
Accepted
time: 172ms
memory: 202408kb

input:

5000 25
-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 -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 -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...

output:

836059165

result:

ok 1 number(s): "836059165"

Test #25:

score: 0
Accepted
time: 193ms
memory: 204476kb

input:

5000 25
-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 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 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...

output:

747198137

result:

ok 1 number(s): "747198137"

Test #26:

score: 0
Accepted
time: 225ms
memory: 202272kb

input:

5000 25
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 -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 -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 ...

output:

915679440

result:

ok 1 number(s): "915679440"

Test #27:

score: 0
Accepted
time: 216ms
memory: 202384kb

input:

5000 25
-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 -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 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 ...

output:

129598521

result:

ok 1 number(s): "129598521"

Test #28:

score: 0
Accepted
time: 196ms
memory: 202312kb

input:

5000 25
-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 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 -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...

output:

678292635

result:

ok 1 number(s): "678292635"

Test #29:

score: 0
Accepted
time: 237ms
memory: 202436kb

input:

5000 25
-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 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 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 -...

output:

570879180

result:

ok 1 number(s): "570879180"

Test #30:

score: 0
Accepted
time: 226ms
memory: 202268kb

input:

5000 25
-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 -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 -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...

output:

497284899

result:

ok 1 number(s): "497284899"

Test #31:

score: 0
Accepted
time: 173ms
memory: 204460kb

input:

5000 25
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 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 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 ...

output:

547200460

result:

ok 1 number(s): "547200460"

Test #32:

score: 0
Accepted
time: 181ms
memory: 204496kb

input:

5000 25
-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 -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 -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 ...

output:

431564537

result:

ok 1 number(s): "431564537"

Test #33:

score: 0
Accepted
time: 196ms
memory: 202272kb

input:

5000 25
-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 -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 -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...

output:

944967577

result:

ok 1 number(s): "944967577"

Test #34:

score: 0
Accepted
time: 198ms
memory: 202472kb

input:

5000 25
-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 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 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...

output:

205819355

result:

ok 1 number(s): "205819355"

Test #35:

score: 0
Accepted
time: 199ms
memory: 202412kb

input:

5000 25
-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 -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 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...

output:

307666691

result:

ok 1 number(s): "307666691"

Test #36:

score: 0
Accepted
time: 175ms
memory: 202388kb

input:

5000 25
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 -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 -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 ...

output:

975555440

result:

ok 1 number(s): "975555440"

Test #37:

score: 0
Accepted
time: 199ms
memory: 204436kb

input:

5000 25
-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 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 -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 -...

output:

954115106

result:

ok 1 number(s): "954115106"

Test #38:

score: 0
Accepted
time: 179ms
memory: 202316kb

input:

5000 25
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 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 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 -...

output:

20240102

result:

ok 1 number(s): "20240102"

Test #39:

score: 0
Accepted
time: 198ms
memory: 202436kb

input:

5000 25
-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 -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 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 ...

output:

888096663

result:

ok 1 number(s): "888096663"

Test #40:

score: 0
Accepted
time: 207ms
memory: 202412kb

input:

5000 25
-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 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 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 ...

output:

753978167

result:

ok 1 number(s): "753978167"

Test #41:

score: 0
Accepted
time: 179ms
memory: 202468kb

input:

5000 45
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 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 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 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

377962368

result:

ok 1 number(s): "377962368"

Test #42:

score: 0
Accepted
time: 228ms
memory: 202400kb

input:

5000 45
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 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 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 -1 1 1 1 -1 1 1 -1 1 1 1 1...

output:

262524907

result:

ok 1 number(s): "262524907"

Test #43:

score: 0
Accepted
time: 195ms
memory: 202352kb

input:

5000 45
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 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 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 1 1 1 1 1 -1 1 -1 1 1 1 1 ...

output:

684504852

result:

ok 1 number(s): "684504852"

Test #44:

score: 0
Accepted
time: 182ms
memory: 202336kb

input:

5000 45
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 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 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 1 1 1 1 -1 1 1 1 1 1 1 1 1 ...

output:

256186185

result:

ok 1 number(s): "256186185"

Test #45:

score: 0
Accepted
time: 182ms
memory: 202436kb

input:

5000 45
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 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 -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 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

56452003

result:

ok 1 number(s): "56452003"

Test #46:

score: 0
Accepted
time: 186ms
memory: 202408kb

input:

5000 45
-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 -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 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -...

output:

353171752

result:

ok 1 number(s): "353171752"

Test #47:

score: 0
Accepted
time: 208ms
memory: 204436kb

input:

5000 45
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 -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 -1 -1 -1 -1 -1 -1 -1 -1 1 -1 -1 -1 -1 -...

output:

494279764

result:

ok 1 number(s): "494279764"

Test #48:

score: 0
Accepted
time: 180ms
memory: 202268kb

input:

5000 45
-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 -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 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1...

output:

863796400

result:

ok 1 number(s): "863796400"

Test #49:

score: 0
Accepted
time: 220ms
memory: 204460kb

input:

5000 45
-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 -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 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -...

output:

883427667

result:

ok 1 number(s): "883427667"

Test #50:

score: 0
Accepted
time: 207ms
memory: 202272kb

input:

5000 45
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 -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 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 -1 ...

output:

435945626

result:

ok 1 number(s): "435945626"

Test #51:

score: 0
Accepted
time: 221ms
memory: 202336kb

input:

5000 64
-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 -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 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -...

output:

144231886

result:

ok 1 number(s): "144231886"

Test #52:

score: 0
Accepted
time: 219ms
memory: 202384kb

input:

5000 43
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 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 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 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

448366527

result:

ok 1 number(s): "448366527"

Test #53:

score: 0
Accepted
time: 185ms
memory: 204472kb

input:

5000 0
-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 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 -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 ...

output:

961512634

result:

ok 1 number(s): "961512634"

Test #54:

score: 0
Accepted
time: 189ms
memory: 202352kb

input:

5000 0
-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 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 -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...

output:

356936487

result:

ok 1 number(s): "356936487"

Test #55:

score: 0
Accepted
time: 200ms
memory: 204452kb

input:

5000 0
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 -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 -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 ...

output:

973390554

result:

ok 1 number(s): "973390554"

Test #56:

score: 0
Accepted
time: 152ms
memory: 202428kb

input:

5000 100
-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 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 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 ...

output:

906315241

result:

ok 1 number(s): "906315241"

Test #57:

score: 0
Accepted
time: 206ms
memory: 202268kb

input:

5000 100
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 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 -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 ...

output:

906315241

result:

ok 1 number(s): "906315241"

Test #58:

score: 0
Accepted
time: 183ms
memory: 202352kb

input:

5000 100
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 -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 -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...

output:

906315241

result:

ok 1 number(s): "906315241"

Test #59:

score: 0
Accepted
time: 195ms
memory: 202388kb

input:

5000 100
-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 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 -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 -...

output:

906315241

result:

ok 1 number(s): "906315241"

Test #60:

score: 0
Accepted
time: 229ms
memory: 202400kb

input:

5000 100
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 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 -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 ...

output:

906315241

result:

ok 1 number(s): "906315241"

Test #61:

score: 0
Accepted
time: 204ms
memory: 202360kb

input:

4998 5
-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 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 -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...

output:

335960136

result:

ok 1 number(s): "335960136"

Test #62:

score: 0
Accepted
time: 177ms
memory: 202348kb

input:

4998 5
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 -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 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 ...

output:

931188852

result:

ok 1 number(s): "931188852"

Test #63:

score: 0
Accepted
time: 214ms
memory: 202384kb

input:

4998 5
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 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 -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...

output:

747827219

result:

ok 1 number(s): "747827219"

Test #64:

score: 0
Accepted
time: 3ms
memory: 5628kb

input:

1 9
-1

output:

176356503

result:

ok 1 number(s): "176356503"

Test #65:

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

input:

2 69
-1 1

output:

857232356

result:

ok 1 number(s): "857232356"

Test #66:

score: 0
Accepted
time: 3ms
memory: 5748kb

input:

3 63
-1 -1 1

output:

296264521

result:

ok 1 number(s): "296264521"