QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#136294#5039. Black and WhitePetroTarnavskyi#RE 13ms50524kbC++172.6kb2023-08-07 19:21:342023-08-07 19:21:37

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-08-07 19:21:37]
  • 评测
  • 测评结果:RE
  • 用时:13ms
  • 内存:50524kb
  • [2023-08-07 19:21:34]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define FOR(i, a, b) for (int i = (a); i<(b); ++i)
#define RFOR(i, b, a) for (int i = (b)-1; i>=(a); --i)
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define FILL(a, b) memset(a, b, sizeof(a))

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;

const int mod = 998244353;
int add(int a, int b){
	return (a + b < mod) ? (a + b) : (a + b - mod);
}
int mult(int a, int b){
	return 1LL * a * b % mod;
}
int binpow(int a, int n){
	int res = 1;
	while(n){
		if(n & 1)
			res = mult(res, a);
		a = mult(a, a);
		n /= 2;
	}
	return res;
}


const int N = 1000;
int fact[N], ober[N];


map<int, int> dp[N][N];

int F(int n, int m, int k)
{
	if (dp[n][m].count(k)) return dp[n][m][k];
	//if (n == 0 && m == 0) return (k == 0); // ?
	if(n == 0) return (k == 0);
	
	dp[n][m][k] = 0;
	FOR(sz, 0, m + 1){
		int nk = k;
		if(sz % 2){
			if(n % 2)
				nk--;
			else
				nk++;
		}
		
		dp[n][m][k] += F(n - 1, sz, nk);
	}
	return dp[n][m][k];
}



int C(int n, int k){
	if(k < 0 || k > n)
		return 0;
	return mult(fact[n], mult(ober[k], ober[n - k]));
	
}

void prec(){
	fact[0] = 1;
	FOR(i, 1, N)
		fact[i] = mult(fact[i - 1], i);
		
	ober[N - 1] = binpow(fact[N - 1], mod - 2);
	RFOR(i, N, 1)
		ober[i - 1] = mult(ober[i], i);
}

int solve(int n, int m, int k){
	int l = -(min(n, m) / 2);
	int r = ((min(n, m) + 1) / 2);
	
	return mult(C((n + m) / 2, k - l), C((n + m + 1) / 2, r - k));
}

void fin(int val, int n, int m){
	FOR(i, 0, 20){
		FOR(j, 0, 20){
			int n0 = (n + m) / 2;
			int m0 = (n + m + 1) / 2;

			if(mult(C(n0, i), C(m0, j)) == val){
					cout << n0 << " " << i << " " << m0 << " " << j << " " << val << endl;
					return;
			}
		}
	}
	cerr << "bad" << endl;
	cerr << n << " " << m << " " << val << endl;
	exit(0);
	assert(0);
}


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	prec();
	
	int t;
	cin >> t;
	while(t--){
		int n, m, k;
		cin >> n >> m >> k;
		if(n > m)
			k = (1LL * n * m) % 2 - k;
			
		cout << solve(n, m, k) << "\n";
	}
	/*
	int n, m;
	cin >> n >> m;
	
	int mn = 10, mx = -10;
	FOR (k, -5, 6)
	{
		F(n, m, k);
		if(dp[n][m][k] != 0){
			mn = min(mn, k);
			mx = max(mx, k);
		}
		cout << k << ' ' << dp[n][m][k] << " " << solve(n, m, k) << '\n';
		assert(dp[n][m][k] == solve(n, m, k));
		fin(dp[n][m][k], n, m);
	}
	cerr << mn << " " << mx << endl;
	*/
	
	return 0;
}


Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

5
1 1 0
1 1 -1
2 2 1
2 2 0
4 4 1

output:

1
0
1
4
16

result:

ok 5 number(s): "1 0 1 4 16"

Test #2:

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

input:

100
1 1 -10
1 1 -9
1 1 -8
1 1 -7
1 1 -6
1 1 -5
1 1 -4
1 1 -3
1 1 -2
1 1 -1
1 1 0
1 1 1
1 1 2
1 1 3
1 1 4
1 1 5
1 1 6
1 1 7
1 1 8
1 1 9
1 1 10
1 2 -10
1 2 -9
1 2 -8
1 2 -7
1 2 -6
1 2 -5
1 2 -4
1 2 -3
1 2 -2
1 2 -1
1 2 0
1 2 1
1 2 2
1 2 3
1 2 4
1 2 5
1 2 6
1 2 7
1 2 8
1 2 9
1 2 10
1 3 -10
1 3 -9
1 3 -...

output:

0
0
0
0
0
0
0
0
0
0
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
2
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
2
2
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
3
2
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
3
3
0
0
0
0

result:

ok 100 numbers

Test #3:

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

input:

100
1 5 6
1 5 7
1 5 8
1 5 9
1 5 10
1 6 -10
1 6 -9
1 6 -8
1 6 -7
1 6 -6
1 6 -5
1 6 -4
1 6 -3
1 6 -2
1 6 -1
1 6 0
1 6 1
1 6 2
1 6 3
1 6 4
1 6 5
1 6 6
1 6 7
1 6 8
1 6 9
1 6 10
1 7 -10
1 7 -9
1 7 -8
1 7 -7
1 7 -6
1 7 -5
1 7 -4
1 7 -3
1 7 -2
1 7 -1
1 7 0
1 7 1
1 7 2
1 7 3
1 7 4
1 7 5
1 7 6
1 7 7
1 7 8
1 ...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
4
3
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
4
4
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
5
4
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
5
5
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
6

result:

ok 100 numbers

Test #4:

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

input:

100
1 10 1
1 10 2
1 10 3
1 10 4
1 10 5
1 10 6
1 10 7
1 10 8
1 10 9
1 10 10
2 1 -10
2 1 -9
2 1 -8
2 1 -7
2 1 -6
2 1 -5
2 1 -4
2 1 -3
2 1 -2
2 1 -1
2 1 0
2 1 1
2 1 2
2 1 3
2 1 4
2 1 5
2 1 6
2 1 7
2 1 8
2 1 9
2 1 10
2 2 -10
2 2 -9
2 2 -8
2 2 -7
2 2 -6
2 2 -5
2 2 -4
2 2 -3
2 2 -2
2 2 -1
2 2 0
2 2 1
2 2 ...

output:

5
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
2
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
4
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
3
6
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
3
9
3
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

result:

ok 100 numbers

Test #5:

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

input:

100
2 5 -4
2 5 -3
2 5 -2
2 5 -1
2 5 0
2 5 1
2 5 2
2 5 3
2 5 4
2 5 5
2 5 6
2 5 7
2 5 8
2 5 9
2 5 10
2 6 -10
2 6 -9
2 6 -8
2 6 -7
2 6 -6
2 6 -5
2 6 -4
2 6 -3
2 6 -2
2 6 -1
2 6 0
2 6 1
2 6 2
2 6 3
2 6 4
2 6 5
2 6 6
2 6 7
2 6 8
2 6 9
2 6 10
2 7 -10
2 7 -9
2 7 -8
2 7 -7
2 7 -6
2 7 -5
2 7 -4
2 7 -3
2 7 -2...

output:

0
0
0
6
12
3
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
6
16
6
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
10
20
6
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
10
25
10
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
15
30
10
0
0
0
0
0
0
0
0
0
0

result:

ok 100 numbers

Test #6:

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

input:

100
2 10 -9
2 10 -8
2 10 -7
2 10 -6
2 10 -5
2 10 -4
2 10 -3
2 10 -2
2 10 -1
2 10 0
2 10 1
2 10 2
2 10 3
2 10 4
2 10 5
2 10 6
2 10 7
2 10 8
2 10 9
2 10 10
3 1 -10
3 1 -9
3 1 -8
3 1 -7
3 1 -6
3 1 -5
3 1 -4
3 1 -3
3 1 -2
3 1 -1
3 1 0
3 1 1
3 1 2
3 1 3
3 1 4
3 1 5
3 1 6
3 1 7
3 1 8
3 1 9
3 1 10
3 2 -10
...

output:

0
0
0
0
0
0
0
0
15
36
15
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
2
2
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
6
3
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
9
9
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
4
18
12
1
0
0
0
0

result:

ok 100 numbers

Test #7:

score: 0
Accepted
time: 6ms
memory: 50472kb

input:

100
3 4 7
3 4 8
3 4 9
3 4 10
3 5 -10
3 5 -9
3 5 -8
3 5 -7
3 5 -6
3 5 -5
3 5 -4
3 5 -3
3 5 -2
3 5 -1
3 5 0
3 5 1
3 5 2
3 5 3
3 5 4
3 5 5
3 5 6
3 5 7
3 5 8
3 5 9
3 5 10
3 6 -10
3 6 -9
3 6 -8
3 6 -7
3 6 -6
3 6 -5
3 6 -4
3 6 -3
3 6 -2
3 6 -1
3 6 0
3 6 1
3 6 2
3 6 3
3 6 4
3 6 5
3 6 6
3 6 7
3 6 8
3 6 9
3 ...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
4
24
24
4
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
10
40
30
4
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
10
50
50
10
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
20
75
60
10
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
20
90
90

result:

ok 100 numbers

Test #8:

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

input:

100
3 9 2
3 9 3
3 9 4
3 9 5
3 9 6
3 9 7
3 9 8
3 9 9
3 9 10
3 10 -10
3 10 -9
3 10 -8
3 10 -7
3 10 -6
3 10 -5
3 10 -4
3 10 -3
3 10 -2
3 10 -1
3 10 0
3 10 1
3 10 2
3 10 3
3 10 4
3 10 5
3 10 6
3 10 7
3 10 8
3 10 9
3 10 10
4 1 -10
4 1 -9
4 1 -8
4 1 -7
4 1 -6
4 1 -5
4 1 -4
4 1 -3
4 1 -2
4 1 -1
4 1 0
4 1 1...

output:

20
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
35
126
105
20
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
2
3
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
3
9
3
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
12
18
4
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

result:

ok 100 numbers

Test #9:

score: 0
Accepted
time: 6ms
memory: 50340kb

input:

100
4 4 -3
4 4 -2
4 4 -1
4 4 0
4 4 1
4 4 2
4 4 3
4 4 4
4 4 5
4 4 6
4 4 7
4 4 8
4 4 9
4 4 10
4 5 -10
4 5 -9
4 5 -8
4 5 -7
4 5 -6
4 5 -5
4 5 -4
4 5 -3
4 5 -2
4 5 -1
4 5 0
4 5 1
4 5 2
4 5 3
4 5 4
4 5 5
4 5 6
4 5 7
4 5 8
4 5 9
4 5 10
4 6 -10
4 6 -9
4 6 -8
4 6 -7
4 6 -6
4 6 -5
4 6 -4
4 6 -3
4 6 -2
4 6 -1...

output:

0
1
16
36
16
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
5
40
60
20
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
5
50
100
50
5
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
15
100
150
60
5
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
15
120
225
120
15
0
0
0
0
0
0
0
0
0
0

result:

ok 100 numbers

Test #10:

score: 0
Accepted
time: 8ms
memory: 50316kb

input:

100
4 9 -8
4 9 -7
4 9 -6
4 9 -5
4 9 -4
4 9 -3
4 9 -2
4 9 -1
4 9 0
4 9 1
4 9 2
4 9 3
4 9 4
4 9 5
4 9 6
4 9 7
4 9 8
4 9 9
4 9 10
4 10 -10
4 10 -9
4 10 -8
4 10 -7
4 10 -6
4 10 -5
4 10 -4
4 10 -3
4 10 -2
4 10 -1
4 10 0
4 10 1
4 10 2
4 10 3
4 10 4
4 10 5
4 10 6
4 10 7
4 10 8
4 10 9
4 10 10
5 1 -10
5 1 -9...

output:

0
0
0
0
0
0
35
210
315
140
15
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
35
245
441
245
35
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
3
3
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
3
12
6
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
4
24
24
4
0
0
0
0
0

result:

ok 100 numbers

Test #11:

score: 0
Accepted
time: 10ms
memory: 50468kb

input:

100
5 3 8
5 3 9
5 3 10
5 4 -10
5 4 -9
5 4 -8
5 4 -7
5 4 -6
5 4 -5
5 4 -4
5 4 -3
5 4 -2
5 4 -1
5 4 0
5 4 1
5 4 2
5 4 3
5 4 4
5 4 5
5 4 6
5 4 7
5 4 8
5 4 9
5 4 10
5 5 -10
5 5 -9
5 5 -8
5 5 -7
5 5 -6
5 5 -5
5 5 -4
5 5 -3
5 5 -2
5 5 -1
5 5 0
5 5 1
5 5 2
5 5 3
5 5 4
5 5 5
5 5 6
5 5 7
5 5 8
5 5 9
5 5 10
5...

output:

0
0
0
0
0
0
0
0
0
0
0
1
20
60
40
5
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
25
100
100
25
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
6
75
200
150
30
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
6
90
300
300
90
6
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
21
210
525
420
105

result:

ok 100 numbers

Test #12:

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

input:

100
5 8 3
5 8 4
5 8 5
5 8 6
5 8 7
5 8 8
5 8 9
5 8 10
5 9 -10
5 9 -9
5 9 -8
5 9 -7
5 9 -6
5 9 -5
5 9 -4
5 9 -3
5 9 -2
5 9 -1
5 9 0
5 9 1
5 9 2
5 9 3
5 9 4
5 9 5
5 9 6
5 9 7
5 9 8
5 9 9
5 9 10
5 10 -10
5 10 -9
5 10 -8
5 10 -7
5 10 -6
5 10 -5
5 10 -4
5 10 -3
5 10 -2
5 10 -1
5 10 0
5 10 1
5 10 2
5 10 3
...

output:

6
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
21
245
735
735
245
21
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
56
490
1176
980
280
21
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
3
4
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
6
16
6
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

result:

ok 100 numbers

Test #13:

score: 0
Accepted
time: 9ms
memory: 50268kb

input:

100
6 3 -2
6 3 -1
6 3 0
6 3 1
6 3 2
6 3 3
6 3 4
6 3 5
6 3 6
6 3 7
6 3 8
6 3 9
6 3 10
6 4 -10
6 4 -9
6 4 -8
6 4 -7
6 4 -6
6 4 -5
6 4 -4
6 4 -3
6 4 -2
6 4 -1
6 4 0
6 4 1
6 4 2
6 4 3
6 4 4
6 4 5
6 4 6
6 4 7
6 4 8
6 4 9
6 4 10
6 5 -10
6 5 -9
6 5 -8
6 5 -7
6 5 -6
6 5 -5
6 5 -4
6 5 -3
6 5 -2
6 5 -1
6 5 0
...

output:

4
30
40
10
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
5
50
100
50
5
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
30
150
200
75
6
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
36
225
400
225
36
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
7
126
525
700
315
42
1
0
0
0
0
0
0
0
0
0
0

result:

ok 100 numbers

Test #14:

score: 0
Accepted
time: 10ms
memory: 50376kb

input:

100
6 8 -7
6 8 -6
6 8 -5
6 8 -4
6 8 -3
6 8 -2
6 8 -1
6 8 0
6 8 1
6 8 2
6 8 3
6 8 4
6 8 5
6 8 6
6 8 7
6 8 8
6 8 9
6 8 10
6 9 -10
6 9 -9
6 9 -8
6 9 -7
6 9 -6
6 9 -5
6 9 -4
6 9 -3
6 9 -2
6 9 -1
6 9 0
6 9 1
6 9 2
6 9 3
6 9 4
6 9 5
6 9 6
6 9 7
6 9 8
6 9 9
6 9 10
6 10 -10
6 10 -9
6 10 -8
6 10 -7
6 10 -6
6...

output:

0
0
0
0
7
147
735
1225
735
147
7
0
0
0
0
0
0
0
0
0
0
0
0
0
0
28
392
1470
1960
980
168
7
0
0
0
0
0
0
0
0
0
0
0
0
0
0
28
448
1960
3136
1960
448
28
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
4
4
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
6
20
10
0
0
0
0
0
0
0

result:

ok 100 numbers

Test #15:

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

input:

100
7 2 9
7 2 10
7 3 -10
7 3 -9
7 3 -8
7 3 -7
7 3 -6
7 3 -5
7 3 -4
7 3 -3
7 3 -2
7 3 -1
7 3 0
7 3 1
7 3 2
7 3 3
7 3 4
7 3 5
7 3 6
7 3 7
7 3 8
7 3 9
7 3 10
7 4 -10
7 4 -9
7 4 -8
7 4 -7
7 4 -6
7 4 -5
7 4 -4
7 4 -3
7 4 -2
7 4 -1
7 4 0
7 4 1
7 4 2
7 4 3
7 4 4
7 4 5
7 4 6
7 4 7
7 4 8
7 4 9
7 4 10
7 5 -10...

output:

0
0
0
0
0
0
0
0
0
0
0
10
50
50
10
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
5
60
150
100
15
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
6
90
300
300
90
6
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
42
315
700
525
126
7
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
49
441
1225
1225
441
49

result:

ok 100 numbers

Test #16:

score: 0
Accepted
time: 6ms
memory: 50420kb

input:

100
7 7 4
7 7 5
7 7 6
7 7 7
7 7 8
7 7 9
7 7 10
7 8 -10
7 8 -9
7 8 -8
7 8 -7
7 8 -6
7 8 -5
7 8 -4
7 8 -3
7 8 -2
7 8 -1
7 8 0
7 8 1
7 8 2
7 8 3
7 8 4
7 8 5
7 8 6
7 8 7
7 8 8
7 8 9
7 8 10
7 9 -10
7 9 -9
7 9 -8
7 9 -7
7 9 -6
7 9 -5
7 9 -4
7 9 -3
7 9 -2
7 9 -1
7 9 0
7 9 1
7 9 2
7 9 3
7 9 4
7 9 5
7 9 6
7 ...

output:

1
0
0
0
0
0
0
0
0
0
0
0
0
0
8
196
1176
2450
1960
588
56
1
0
0
0
0
0
0
0
0
0
0
0
0
0
8
224
1568
3920
3920
1568
224
8
0
0
0
0
0
0
0
0
0
0
0
0
0
36
672
3528
7056
5880
2016
252
8
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
4
5
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

result:

ok 100 numbers

Test #17:

score: 0
Accepted
time: 7ms
memory: 50348kb

input:

100
8 2 -1
8 2 0
8 2 1
8 2 2
8 2 3
8 2 4
8 2 5
8 2 6
8 2 7
8 2 8
8 2 9
8 2 10
8 3 -10
8 3 -9
8 3 -8
8 3 -7
8 3 -6
8 3 -5
8 3 -4
8 3 -3
8 3 -2
8 3 -1
8 3 0
8 3 1
8 3 2
8 3 3
8 3 4
8 3 5
8 3 6
8 3 7
8 3 8
8 3 9
8 3 10
8 4 -10
8 4 -9
8 4 -8
8 4 -7
8 4 -6
8 4 -5
8 4 -4
8 4 -3
8 4 -2
8 4 -1
8 4 0
8 4 1
8...

output:

10
25
10
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
10
60
75
20
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
15
120
225
120
15
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
6
105
420
525
210
21
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
7
147
735
1225
735
147
7
0
0
0
0
0
0
0
0
0
0
0

result:

ok 100 numbers

Test #18:

score: 0
Accepted
time: 8ms
memory: 50308kb

input:

100
8 7 -6
8 7 -5
8 7 -4
8 7 -3
8 7 -2
8 7 -1
8 7 0
8 7 1
8 7 2
8 7 3
8 7 4
8 7 5
8 7 6
8 7 7
8 7 8
8 7 9
8 7 10
8 8 -10
8 8 -9
8 8 -8
8 8 -7
8 8 -6
8 8 -5
8 8 -4
8 8 -3
8 8 -2
8 8 -1
8 8 0
8 8 1
8 8 2
8 8 3
8 8 4
8 8 5
8 8 6
8 8 7
8 8 8
8 8 9
8 8 10
8 9 -10
8 9 -9
8 9 -8
8 9 -7
8 9 -6
8 9 -5
8 9 -4...

output:

0
0
1
56
588
1960
2450
1176
196
8
0
0
0
0
0
0
0
0
0
0
0
0
0
1
64
784
3136
4900
3136
784
64
1
0
0
0
0
0
0
0
0
0
0
0
0
9
288
2352
7056
8820
4704
1008
72
1
0
0
0
0
0
0
0
0
0
0
0
0
9
324
3024
10584
15876
10584
3024
324
9
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
5
5
0
0
0
0
0
0
0
0

result:

ok 100 numbers

Test #19:

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

input:

100
9 1 10
9 2 -10
9 2 -9
9 2 -8
9 2 -7
9 2 -6
9 2 -5
9 2 -4
9 2 -3
9 2 -2
9 2 -1
9 2 0
9 2 1
9 2 2
9 2 3
9 2 4
9 2 5
9 2 6
9 2 7
9 2 8
9 2 9
9 2 10
9 3 -10
9 3 -9
9 3 -8
9 3 -7
9 3 -6
9 3 -5
9 3 -4
9 3 -3
9 3 -2
9 3 -1
9 3 0
9 3 1
9 3 2
9 3 3
9 3 4
9 3 5
9 3 6
9 3 7
9 3 8
9 3 9
9 3 10
9 4 -10
9 4 -...

output:

0
0
0
0
0
0
0
0
0
0
10
30
15
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
20
90
90
20
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
15
140
315
210
35
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
21
245
735
735
245
21
0
0
0
0
0
0
0
0
0
0
0
0
0
0
7
168
980
1960
1470
392
28
0

result:

ok 100 numbers

Test #20:

score: 0
Accepted
time: 6ms
memory: 50468kb

input:

100
9 6 5
9 6 6
9 6 7
9 6 8
9 6 9
9 6 10
9 7 -10
9 7 -9
9 7 -8
9 7 -7
9 7 -6
9 7 -5
9 7 -4
9 7 -3
9 7 -2
9 7 -1
9 7 0
9 7 1
9 7 2
9 7 3
9 7 4
9 7 5
9 7 6
9 7 7
9 7 8
9 7 9
9 7 10
9 8 -10
9 8 -9
9 8 -8
9 8 -7
9 8 -6
9 8 -5
9 8 -4
9 8 -3
9 8 -2
9 8 -1
9 8 0
9 8 1
9 8 2
9 8 3
9 8 4
9 8 5
9 8 6
9 8 7
9 ...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
8
224
1568
3920
3920
1568
224
8
0
0
0
0
0
0
0
0
0
0
0
0
1
72
1008
4704
8820
7056
2352
288
9
0
0
0
0
0
0
0
0
0
0
0
0
1
81
1296
7056
15876
15876
7056
1296
81
1
0
0
0
0
0
0
0
0
0
0
0
10
405
4320
17640
31752
26460
10080
1620
90
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
5

result:

ok 100 numbers

Test #21:

score: 0
Accepted
time: 13ms
memory: 50352kb

input:

100
10 1 0
10 1 1
10 1 2
10 1 3
10 1 4
10 1 5
10 1 6
10 1 7
10 1 8
10 1 9
10 1 10
10 2 -10
10 2 -9
10 2 -8
10 2 -7
10 2 -6
10 2 -5
10 2 -4
10 2 -3
10 2 -2
10 2 -1
10 2 0
10 2 1
10 2 2
10 2 3
10 2 4
10 2 5
10 2 6
10 2 7
10 2 8
10 2 9
10 2 10
10 3 -10
10 3 -9
10 3 -8
10 3 -7
10 3 -6
10 3 -5
10 3 -4
10...

output:

6
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
15
36
15
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
20
105
126
35
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
35
245
441
245
35
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
21
280
980
1176
490
56
0
0
0
0
0
0
0
0
0
0
0
0
0

result:

ok 100 numbers

Test #22:

score: 0
Accepted
time: 8ms
memory: 50348kb

input:

100
10 6 -5
10 6 -4
10 6 -3
10 6 -2
10 6 -1
10 6 0
10 6 1
10 6 2
10 6 3
10 6 4
10 6 5
10 6 6
10 6 7
10 6 8
10 6 9
10 6 10
10 7 -10
10 7 -9
10 7 -8
10 7 -7
10 7 -6
10 7 -5
10 7 -4
10 7 -3
10 7 -2
10 7 -1
10 7 0
10 7 1
10 7 2
10 7 3
10 7 4
10 7 5
10 7 6
10 7 7
10 7 8
10 7 9
10 7 10
10 8 -10
10 8 -9
10...

output:

0
0
28
448
1960
3136
1960
448
28
0
0
0
0
0
0
0
0
0
0
0
0
0
8
252
2016
5880
7056
3528
672
36
0
0
0
0
0
0
0
0
0
0
0
0
0
9
324
3024
10584
15876
10584
3024
324
9
0
0
0
0
0
0
0
0
0
0
0
1
90
1620
10080
26460
31752
17640
4320
405
10
0
0
0
0
0
0
0
0
0
0
0
1
100
2025
14400
44100
63504
44100
14400
2025
100
1
...

result:

ok 100 numbers

Test #23:

score: -100
Runtime Error

input:

100
30062 71054 -100000
30062 71054 -100000
30062 71054 -100000
30062 71054 40992
30062 71054 40991
30062 71054 40993
30062 71054 -30062
30062 71054 -30063
30062 71054 -30061
30062 71054 -40992
30062 71054 -40993
30062 71054 -40991
30062 71054 100000
30062 71054 100000
30062 71054 100000
30062 71054...

output:


result: