QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#601571#4885. Triangular Cactus PathszltAC ✓231ms191184kbC++142.9kb2024-09-30 07:52:022024-09-30 07:52:03

Judging History

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

  • [2024-09-30 07:52:03]
  • 评测
  • 测评结果:AC
  • 用时:231ms
  • 内存:191184kb
  • [2024-09-30 07:52:02]
  • 提交

answer

#include <bits/stdc++.h>
#define pb emplace_back
#define fst first
#define scd second
#define mkp make_pair
#define mems(a, x) memset((a), (x), sizeof(a))

using namespace std;
typedef long long ll;
typedef double db;
typedef unsigned long long ull;
typedef long double ldb;
typedef pair<ll, ll> pii;

const int maxn = 1000100;
const int logn = 21;
const int N = 1000000;
const ll mod = 998244353;

inline ll qpow(ll b, ll p) {
	ll res = 1;
	while (p) {
		if (p & 1) {
			res = res * b % mod;
		}
		b = b * b % mod;
		p >>= 1;
	}
	return res;
}

int n, m, q;
ll fac[maxn], ifac[maxn];

inline ll C(ll n, ll m) {
	if (n < m || n < 0 || m < 0) {
		return 0;
	} else {
		return fac[n] * ifac[m] % mod * ifac[n - m] % mod;
	}
}

int dfn[maxn], low[maxn], tim, stk[maxn], top, nt, f[maxn], g[maxn];
vector<int> G[maxn], T[maxn];

void dfs(int u, int fa) {
	dfn[u] = low[u] = ++tim;
	stk[++top] = u;
	for (int v : G[u]) {
		if (v == fa) {
			continue;
		}
		if (!dfn[v]) {
			dfs(v, u);
			low[u] = min(low[u], low[v]);
			if (low[v] >= dfn[u]) {
				++nt;
				while (1) {
					int x = stk[top--];
					T[x].pb(nt);
					T[nt].pb(x);
					if (x == v) {
						break;
					}
				}
				T[u].pb(nt);
				T[nt].pb(u);
			}
		} else {
			low[u] = min(low[u], dfn[v]);
		}
	}
}

int st[logn][maxn], fa[maxn];

inline int get(int i, int j) {
	return dfn[i] < dfn[j] ? i : j;
}

inline int qlca(int x, int y) {
	if (x == y) {
		return x;
	}
	x = dfn[x];
	y = dfn[y];
	if (x > y) {
		swap(x, y);
	}
	++x;
	int k = __lg(y - x + 1);
	return get(st[k][x], st[k][y - (1 << k) + 1]);
}

inline int qf(int x, int y) {
	int z = qlca(x, y);
	return f[x] + f[y] - f[z] - f[fa[z]];
}

inline int qg(int x, int y) {
	int z = qlca(x, y);
	return g[x] + g[y] - g[z] - g[fa[z]];
}

void dfs2(int u, int fa) {
	f[u] = f[fa] + (u <= n);
	g[u] = g[fa] + (u > n && (int)T[u].size() == 3);
	dfn[u] = ++tim;
	::fa[u] = fa;
	st[0][tim] = fa;
	for (int v : T[u]) {
		if (v == fa) {
			continue;
		}
		dfs2(v, u);
	}
}

void solve() {
	fac[0] = 1;
	for (int i = 1; i <= N; ++i) {
		fac[i] = fac[i - 1] * i % mod;
	}
	ifac[N] = qpow(fac[N], mod - 2);
	for (int i = N - 1; ~i; --i) {
		ifac[i] = ifac[i + 1] * (i + 1) % mod;
	}
	scanf("%d%d", &n, &m);
	nt = n;
	while (m--) {
		int u, v;
		scanf("%d%d", &u, &v);
		G[u].pb(v);
		G[v].pb(u);
	}
	dfs(1, -1);
	tim = 0;
	dfs2(1, 0);
	for (int j = 1; (1 << j) <= nt; ++j) {
		for (int i = 1; i + (1 << j) - 1 <= nt; ++i) {
			st[j][i] = get(st[j - 1][i], st[j - 1][i + (1 << (j - 1))]);
		}
	}
	scanf("%d", &q);
	while (q--) {
		int x, y, k;
		scanf("%d%d%d", &x, &y, &k);
		int d = qf(x, y) - 1;
		if (k < d) {
			puts("0");
			continue;
		}
		int t = qg(x, y);
		printf("%lld\n", C(t, k - d));
	}
}

int main() {
	int T = 1;
	// scanf("%d", &T);
	while (T--) {
		solve();
	}
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 12ms
memory: 80052kb

input:

8 10
1 2
2 3
3 1
3 4
4 5
5 6
6 4
4 7
7 8
8 4
6
1 1 0
1 1 1
1 4 3
6 2 4
5 7 4
3 4 2

output:

1
0
1
2
1
0

result:

ok 6 numbers

Test #2:

score: 0
Accepted
time: 18ms
memory: 78160kb

input:

2 1
1 2
8
1 1 0
1 1 1
1 2 0
1 2 1
2 1 0
2 1 1
2 2 0
2 2 1

output:

1
0
0
1
0
1
1
0

result:

ok 8 numbers

Test #3:

score: 0
Accepted
time: 53ms
memory: 87868kb

input:

50 70
41 24
9 15
29 19
21 11
1 14
5 27
34 48
10 32
34 49
46 3
22 33
34 39
16 30
22 45
7 16
25 30
43 17
22 44
5 25
41 49
29 32
39 25
10 4
45 27
13 38
29 7
3 35
14 30
50 2
8 11
13 35
18 26
34 40
38 36
7 19
12 3
25 26
30 42
21 8
12 46
44 33
14 31
47 2
25 46
20 19
49 24
15 43
18 25
13 36
27 22
4 32
30 3...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
3
0
0
0
0
0
4
0
0
15
5
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
10
2
0
0
0
0
0
6
0
0
0
0
0
0
0
0
7
0
0
0
0
3
0
6
0
0
0
0
7
0
6
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
15
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0...

result:

ok 200000 numbers

Test #4:

score: 0
Accepted
time: 11ms
memory: 89868kb

input:

99 147
26 66
27 92
75 90
91 64
69 15
70 61
52 59
3 86
41 99
47 71
26 43
99 83
43 80
42 69
4 75
66 71
68 38
31 57
5 91
74 2
90 4
32 11
1 31
77 5
76 8
12 60
79 42
48 89
22 14
36 76
45 91
43 65
99 86
69 16
85 11
19 28
15 52
49 85
84 68
28 85
93 68
16 15
42 9
71 51
72 92
84 2
13 50
9 44
97 78
11 60
98 3...

output:

0
0
0
231867712
1176
13983816
0
838535532
57966928
0
259558945
995677382
49
58518925
231867712
0
0
0
0
699660129
0
18424
0
0
0
0
425254360
596115770
0
0
0
0
435689908
0
0
578343994
351113550
0
0
1
186830027
578343994
211876
0
596115770
0
186830027
0
58518925
0
1906884
304945365
0
304945365
0
1
0
0
2...

result:

ok 99 numbers

Test #5:

score: 0
Accepted
time: 192ms
memory: 170100kb

input:

199999 299997
46838 7499
94674 132821
113340 39783
26895 102985
48012 197970
142680 5947
103806 184307
136126 111090
130225 128927
158116 75097
24205 199579
53104 138584
43659 53794
139767 62161
93131 22718
129300 168198
49873 179193
194655 168999
113749 118408
37725 48137
151840 84343
111148 8100
1...

output:

712824194
0
0
0
0
320802700
0
381157374
0
833072245
0
539501991
0
0
0
0
165868657
793806843
822184128
856338717
0
661129134
675908771
975338712
0
0
79921863
945552739
686592487
0
573599683
0
0
0
0
792230751
858673087
0
0
0
891080989
740140757
576820560
0
91314141
340565711
0
0
84853588
883814968
328...

result:

ok 199999 numbers

Test #6:

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

input:

200000 299998
19008 7191
14929 145558
171415 75888
125803 50869
125803 89494
71554 125803
93981 190321
80132 168052
37991 125803
125803 55181
125803 87736
125803 173325
65091 5744
28792 125803
193355 90762
23087 125803
122219 78611
125803 99170
23205 125803
56643 125803
77718 99556
6381 26214
125803...

output:

0
0
1
0
0
1
2
2
2
0
2
1
0
0
0
1
1
1
1
0
0
0
1
2
0
0
0
0
0
0
0
0
0
0
0
1
0
1
0
0
0
0
2
0
0
0
2
0
0
0
1
0
0
0
0
1
1
0
2
0
2
2
1
0
2
1
0
2
2
0
1
0
1
0
0
1
1
0
1
2
2
1
2
1
1
0
0
2
0
0
1
0
0
1
0
0
0
1
0
2
0
2
0
0
2
0
0
0
0
0
1
1
0
1
0
0
1
1
1
1
0
2
0
0
0
0
1
0
1
0
1
0
2
2
1
2
1
1
1
0
0
0
1
0
1
2
0
1
2
0
...

result:

ok 200000 numbers

Test #7:

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

input:

200000 299998
35051 163817
40900 101348
178201 92415
83625 178201
34463 178201
99216 165173
144785 178201
95724 90118
47179 178201
179124 24472
167185 113297
178201 103303
178201 117563
164337 89112
71718 178201
116345 178201
31507 104681
123236 114706
178201 99528
63206 176985
178201 73250
134480 1...

output:

1
2
2
1
2
1
1
2
1
1
1
2
1
2
1
1
2
1
1
1
2
1
1
1
1
1
2
1
2
1
2
1
1
2
1
1
2
1
1
1
1
1
1
2
2
1
2
2
1
2
2
1
2
1
1
2
1
1
1
1
2
1
1
2
1
1
1
1
2
2
2
1
1
1
2
1
2
1
1
1
1
1
1
2
1
2
2
1
1
1
2
2
1
1
1
1
2
1
1
1
1
1
2
1
1
2
1
2
2
1
2
2
1
1
1
2
1
1
2
2
2
2
1
1
2
1
1
1
1
1
2
2
1
1
1
2
1
2
2
2
1
2
1
1
1
1
1
1
1
2
...

result:

ok 200000 numbers

Test #8:

score: 0
Accepted
time: 203ms
memory: 160796kb

input:

200000 299998
367 110813
63425 113525
97438 49705
88365 78641
127917 31635
150617 36277
73986 122706
3862 113109
158117 57923
123299 148860
99434 114967
108733 44232
150884 30511
134689 63252
174091 170877
187878 120179
49168 46850
194653 59914
198504 92123
144466 47484
20176 160377
303 53901
100183...

output:

0
15
1
0
5
0
10
0
0
0
0
0
6
0
0
6
0
0
0
0
5
0
0
1
0
0
4
0
1
0
0
6
0
1
0
1
20
6
0
0
0
0
0
0
0
0
0
0
0
15
5
0
0
0
0
0
1
15
0
15
0
1
0
0
0
0
10
15
0
4
1
0
0
20
0
5
6
5
0
0
4
1
1
6
0
0
0
10
20
0
10
20
0
0
3
6
0
0
0
0
1
0
0
0
5
1
0
10
0
1
0
0
0
0
0
5
0
0
1
0
0
1
1
0
15
4
0
0
0
0
1
15
1
0
5
0
0
0
1
0
0
5
...

result:

ok 200000 numbers

Test #9:

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

input:

200000 299998
168577 140236
91418 46548
97163 149747
159723 196783
135882 29440
42383 197978
68821 138271
50397 46260
132922 152305
119863 23851
157442 72531
9039 107717
10071 198972
121825 39080
137048 110653
53552 1299
122072 37769
149573 2291
114649 123836
177289 101826
175353 106767
158189 11950...

output:

9
0
0
28
84
210
1
126
0
10
0
1
28
0
126
0
0
8
0
8
6
0
1
0
0
0
0
0
28
0
0
1
84
36
0
0
35
0
0
1
0
0
36
0
126
55
9
1
0
45
0
36
1
1
1
28
84
8
36
0
0
0
0
0
0
8
0
126
0
0
0
1
28
0
0
0
0
0
0
0
0
7
7
0
0
0
1
0
0
21
0
28
0
0
0
0
0
0
126
0
0
0
0
0
0
8
36
28
0
0
0
0
56
0
0
0
0
0
126
70
0
15
120
84
0
1
28
0
1
0...

result:

ok 200000 numbers

Test #10:

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

input:

200000 299998
91015 148128
112131 139537
127573 78263
179266 87139
53858 6467
185462 164972
3614 166956
191119 166727
131564 24765
100259 20875
26365 3864
139365 9577
60346 74962
189890 42039
34518 165692
72913 16580
88831 159289
32110 99986
22061 163395
159597 100524
118184 4285
26750 9536
75591 18...

output:

35
56
6
15
84
28
210
84
21
9
70
1
7
21
70
28
21
1
165
165
120
28
56
9
21
56
15
56
8
15
5
35
1
6
8
165
35
56
84
56
5
165
55
84
1
7
9
1
28
1
15
70
56
1
9
6
10
1
8
9
35
1
8
1
1
36
45
56
35
21
1
28
35
1
36
7
36
8
8
10
165
165
7
84
45
21
35
21
1
1
6
70
252
1
1
35
56
21
56
35
28
35
28
10
1
126
21
36
1
9
9...

result:

ok 200000 numbers

Test #11:

score: 0
Accepted
time: 197ms
memory: 155132kb

input:

200000 299998
173800 113709
191467 102780
22898 6509
145405 189615
58525 157360
177263 117040
168472 121643
142353 70517
168034 52062
170154 30064
138914 150559
102593 36027
39527 124368
42909 58645
36049 2834
36359 199446
152352 97803
189883 177330
173137 190624
159282 179479
112962 161688
66466 13...

output:

1
64512240
129024480
17550
6820076
0
91390
378
169911
9880
38320568
286097760
0
1
910944449
565722720
0
65780
20475
315312734
0
44
18424
0
0
732334537
0
478093447
92561040
118755
575757
1140
53524680
8436
10295472
900696486
962598
0
66045
780
685354923
0
0
0
1
340769021
118030185
80730
38608020
0
0
...

result:

ok 200000 numbers

Test #12:

score: 0
Accepted
time: 224ms
memory: 154824kb

input:

200000 299998
9309 2854
49555 37904
186816 70564
186626 84271
154557 85539
135207 131713
98194 199903
185568 152806
115774 155230
22656 186143
30015 91138
185826 93589
184809 198539
18063 130625
74843 188301
113927 23785
23492 159185
129151 108287
156657 127224
83686 64569
142508 153575
154415 11399...

output:

996768010
2123555
637856014
510964037
729818394
970020224
0
12552879
1
320613183
97383695
800072864
628889870
705781936
249043571
234531275
768301297
22537515
199721756
0
111379169
189264529
8256
626883194
262595348
794425127
0
704894314
623824554
52850702
339281417
890674118
621896013
604307599
937...

result:

ok 200000 numbers

Test #13:

score: 0
Accepted
time: 209ms
memory: 161656kb

input:

200000 299998
76960 197873
128472 91810
72899 30789
8859 128540
113299 85869
168603 105592
30851 32501
113397 71027
12782 51894
85860 96645
109357 84579
194663 133271
11680 176061
45600 71812
115779 2054
166564 36697
126544 183799
99314 79359
29609 172047
101385 113686
42712 158223
53237 177394
1331...

output:

173199973
829507931
331933811
464214646
847507693
146960426
288288189
872245315
58512877
265398753
210654988
330658607
560256537
846403539
734617205
963753559
366090369
613032207
971790520
284683761
8856500
955035587
859126976
901953341
6441
976253339
920968520
407137938
314060141
270684839
26804358...

result:

ok 200000 numbers

Test #14:

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

input:

200000 299998
70486 57759
166753 190547
187417 103988
103190 141773
119255 103196
85331 133854
119343 175324
99605 153719
187574 170283
173899 25140
31520 59096
148166 60720
50051 99288
137278 13470
160008 49076
69239 81939
124998 81970
96180 58397
191850 12092
55182 34948
44525 123624
167957 64957
...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
127003567
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 200000 numbers

Test #15:

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

input:

200000 299998
85484 102203
119064 151384
147463 55308
69444 120612
165881 77246
124366 16092
64156 31470
95523 61146
172135 111157
24525 172340
21438 90335
71522 159529
36934 24576
70360 42591
104772 14202
147233 27399
129863 7407
81605 190562
14305 98089
104326 184840
80368 183513
143747 100951
101...

output:

715257012
138415
811930362
748930732
77276827
80479067
812530628
333031107
301498593
65703
416995293
794035258
122393425
62481
161189970
930652172
707632893
574885693
664478657
672525805
198626801
774427606
252612889
300033984
246176005
112109615
947320238
975716013
200327132
559829124
412658632
754...

result:

ok 200000 numbers

Test #16:

score: 0
Accepted
time: 231ms
memory: 169088kb

input:

200000 299998
5598 51579
83944 70726
113271 88298
59706 119428
151184 135184
39141 146731
103002 124882
159210 122944
23973 122168
136927 171096
150561 143808
164621 80589
160606 55120
89922 5041
12349 159791
114739 146305
62673 95038
73483 110218
143525 85013
28332 98132
55122 58546
106180 3992
138...

output:

800333870
944020939
366584310
392851892
68508256
55840713
67550472
979868141
307914167
918348107
691599375
448437496
93447530
435792615
814612858
843624840
11711507
369669005
345371688
484603443
259670248
517268924
522188444
956543317
42120239
76488132
409106665
797721877
411157901
451145760
4919539...

result:

ok 200000 numbers

Test #17:

score: 0
Accepted
time: 164ms
memory: 163204kb

input:

200000 250000
100393 188830
186087 97425
97137 100393
100393 76926
79822 100393
76933 13773
159271 100393
94776 80011
35749 187694
27099 100393
47086 100393
100393 103658
197236 128972
139799 100393
147425 100393
130704 100393
100393 46622
26276 100393
142856 100393
100393 139836
103586 30246
59492 ...

output:

1
1
0
0
0
0
0
0
0
1
1
1
0
0
1
1
0
1
1
1
1
0
1
0
1
1
0
1
1
1
0
0
1
1
0
0
0
1
1
0
0
0
0
0
1
0
2
0
1
0
0
0
1
0
0
0
2
1
1
0
1
1
0
0
1
1
1
1
0
0
1
1
1
0
0
2
1
0
0
0
0
0
1
0
0
0
1
0
2
1
1
1
0
1
1
0
0
1
0
0
0
0
1
1
1
1
0
1
1
1
1
1
2
1
1
0
1
1
0
0
2
0
0
1
0
0
1
0
0
0
0
1
1
1
0
1
1
1
1
0
0
1
1
0
1
1
0
0
0
0
...

result:

ok 200000 numbers

Test #18:

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

input:

200000 250000
159649 167
1350 136841
19978 184411
45104 170418
6416 127559
85301 75347
156280 174640
70456 102434
7675 62358
92992 11100
101621 105633
15562 92253
69745 85295
194315 121550
153254 199419
43231 118207
45399 173459
17401 166125
61456 160564
138041 141873
153899 23589
131924 124948
1898...

output:

2
1
1
0
0
0
1
0
0
1
0
1
3
1
1
1
0
1
0
2
6
1
0
1
0
1
4
0
0
0
0
3
2
0
0
4
2
2
1
0
0
1
0
1
0
1
1
0
1
1
0
2
0
2
0
0
0
0
0
0
0
1
0
0
1
2
0
1
2
1
0
3
0
1
0
3
0
1
0
0
0
0
0
2
2
0
1
1
2
0
0
0
1
0
0
0
1
0
0
0
1
0
1
1
3
0
1
6
1
0
6
1
1
3
1
1
1
4
1
0
3
0
4
0
2
0
0
3
0
0
0
1
0
0
0
1
3
4
0
1
0
3
0
1
0
4
0
0
0
0
...

result:

ok 200000 numbers

Test #19:

score: 0
Accepted
time: 162ms
memory: 163924kb

input:

200000 250000
69349 78353
99346 182985
139467 129966
102780 9786
129013 153281
116768 9213
98822 95046
43477 11906
157504 107534
122085 6000
187249 185174
115771 85956
105184 119164
41073 97256
9687 100363
52427 90544
28128 155750
88550 167059
147740 38825
12142 121190
47820 147762
166391 85729
1063...

output:

2
1
3
4
6
6
1
10
1
1
1
1
1
1
6
3
1
1
1
3
3
4
1
1
5
1
1
1
1
1
4
1
1
1
1
1
1
1
2
1
1
1
1
1
1
4
3
3
1
1
2
3
1
10
1
5
4
1
1
2
1
1
1
4
3
1
1
1
1
1
3
1
3
1
1
2
1
3
1
1
4
10
5
3
1
3
1
3
1
1
1
4
1
3
1
4
4
3
3
3
1
2
1
3
1
4
5
1
4
2
1
1
3
1
1
10
1
1
1
1
2
1
2
1
2
1
1
1
2
2
2
4
1
2
5
1
1
1
1
10
1
1
1
1
4
6
1
1...

result:

ok 200000 numbers

Test #20:

score: 0
Accepted
time: 188ms
memory: 165120kb

input:

200000 250000
198846 18591
63474 15995
73625 115460
121030 27831
178862 175754
152305 9907
32943 60233
57757 191291
73981 191795
183453 53870
52323 90660
159816 76956
155996 129341
12640 50149
128101 143250
177020 38881
123886 17297
21696 183091
180154 3208
158866 59964
162318 142857
172468 164121
1...

output:

0
0
4
0
0
0
0
4
0
0
4
4
0
3
1
0
0
0
0
0
3
0
0
5
1
0
1
4
3
0
5
0
0
0
0
5
1
0
2
0
6
1
0
0
4
0
0
0
0
1
9
4
0
1
3
0
1
0
0
0
0
1
1
0
0
1
0
5
0
6
0
6
3
1
0
0
0
0
1
0
36
0
0
21
0
0
5
1
1
6
1
3
0
10
6
0
0
0
6
0
4
0
0
0
84
0
3
70
1
0
0
1
0
0
1
0
1
3
5
1
0
0
0
0
0
4
3
0
0
3
21
0
1
10
0
3
1
56
0
0
0
0
20
4
3
0...

result:

ok 200000 numbers

Test #21:

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

input:

200000 250000
62780 115539
62791 40736
75735 139791
136264 61827
43883 83688
133005 90205
176458 97337
31899 132625
183743 140532
51561 182157
129131 75246
103468 108518
169029 34361
166547 141285
134582 4229
52757 142776
182972 116917
83775 67525
59801 100848
23385 15576
134531 68991
128628 106855
...

output:

1
35
4
1
9
4
21
15
6
1
1
5
1
10
1
4
2
3
10
4
3
3
4
3
5
6
1
15
7
6
3
1
6
10
6
4
1
4
20
5
2
10
1
4
1
15
1
1
1
6
5
1
1
4
1
15
4
5
5
1
10
6
6
1
15
2
10
1
35
1
6
21
1
1
6
1
4
10
10
3
1
20
10
1
1
1
1
1
6
2
35
6
3
1
3
1
1
15
1
1
1
3
35
1
1
1
35
1
1
4
1
20
1
3
1
1
1
4
35
20
1
6
10
1
10
20
6
10
1
6
1
1
1
1
3...

result:

ok 200000 numbers

Test #22:

score: 0
Accepted
time: 217ms
memory: 161680kb

input:

200000 250000
85785 32293
82855 100396
141323 100160
76351 113603
141321 48949
638 60439
91323 66718
45433 2694
107252 173530
45061 63919
175292 138750
46791 197170
8834 188733
73617 179571
101375 7958
98834 123948
121436 159373
117677 124316
73961 143991
54392 164076
15545 170373
148305 166064
1091...

output:

12376
12376
364
330
7315
0
0
1
1
1140
276
0
0
8008
0
18
12376
0
0
0
3003
38760
0
0
8008
0
0
116280
92378
18564
0
0
1
3060
0
0
5005
0
0
5005
0
680
3124550
0
0
53130
0
11440
0
100947
1352078
125970
0
0
0
1540
19448
0
10626
0
0
1001
495
1
364
12
0
12376
1
13037895
0
15504
0
0
0
8568
286
0
0
0
0
352716
...

result:

ok 200000 numbers

Test #23:

score: 0
Accepted
time: 197ms
memory: 166228kb

input:

200000 250000
58206 182654
55004 39192
178017 93752
155689 109908
125343 150388
173572 134224
186491 81477
129661 156707
65511 34260
96725 28679
16026 62698
95492 50915
50130 122203
113266 190566
104702 133347
121484 147340
133437 71289
61115 71838
68990 23093
140767 70415
146920 99833
75146 194373
...

output:

0
111930
15380937
10514804
0
1
1370754
684342341
0
827957761
55346885
0
62
299563193
806557639
487635
0
918278122
32224114
0
177223276
0
0
0
140254302
708069696
770391120
0
735703650
255750549
0
526735148
855663586
130452370
281918476
5852925
0
844080433
146687094
36749680
722358711
0
324632
0
0
0
5...

result:

ok 200000 numbers

Test #24:

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

input:

200000 250000
8488 45445
106433 161885
62781 150245
156447 131290
20818 71800
17969 43907
183141 196708
75369 30716
193484 134771
89315 149073
186450 80588
117115 140032
83701 33627
180192 142610
59186 183791
73776 42711
29028 40699
173826 155742
164812 107773
181053 189603
88623 95251
75486 85177
1...

output:

193808047
646718095
242737825
293164753
784542880
243607626
0
148827994
1
730028217
586978548
1
422558687
772433130
0
608629362
749471750
773021988
207361268
963376975
57920555
571608719
0
15659307
680934981
822828353
923316240
236602007
891099206
0
368429945
583612167
179088156
157192654
13270261
0...

result:

ok 200000 numbers

Test #25:

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

input:

200000 250000
157974 149214
140697 105615
64507 165368
74277 17018
170086 19479
24963 137321
199370 23741
6872 164295
155198 106632
74330 185866
103662 133352
109979 33000
93187 53238
4818 79298
13968 93983
37744 40274
38060 120527
111968 184145
56753 61447
132480 16270
87390 46133
52343 5710
28652 ...

output:

821869645
76410649
98600511
26316397
412246907
385039982
285262760
552650044
862013212
279125501
236001999
640532127
532171640
144894715
704720903
438894772
881081184
294882503
154083149
243263418
407798606
55510774
830810461
334735902
786086720
800513105
257100526
649736418
208916396
7303940
936892...

result:

ok 200000 numbers

Test #26:

score: 0
Accepted
time: 157ms
memory: 168548kb

input:

200000 199999
33437 83535
56983 83535
83535 128100
163074 83535
53012 83535
83535 184699
703 83535
83535 108496
83535 60567
187461 83535
83535 150579
170503 83535
56605 83535
112250 83535
83535 156095
142538 83535
132788 83535
78627 83535
83535 48867
100952 83535
83535 90786
83535 92757
81158 83535
...

output:

0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
1
0
1
0
1
1
1
1
1
1
0
0
0
0
0
0
1
1
1
1
0
1
1
1
1
1
1
1
1
1
0
0
0
0
0
0
1
1
1
1
0
1
0
1
0
0
0
0
0
1
0
1
0
1
1
0
1
0
1
1
0
0
0
0
0
0
1
0
0
0
0
0
0
0
1
1
0
1
0
0
0
0
0
0
0
0
1
0
1
0
1
1
0
0
0
0
1
0
1
0
0
1
1
1
0
0
1
1
0
0
1
1
1
1
0
0
0
1
1
1
0
1
0
0
1
0
0
1
0
0
0
0
1
1
...

result:

ok 200000 numbers

Test #27:

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

input:

200000 199999
73392 56379
116130 16764
137719 188409
129846 65208
123548 51774
20005 199794
158462 169418
43561 34456
164655 58082
195182 155831
74261 188770
153151 106897
3567 165072
74824 120179
143391 152906
44153 128513
64048 186603
143391 32756
165778 144448
89309 112971
156364 132077
76130 677...

output:

0
1
0
0
0
1
0
1
0
0
0
0
1
0
0
0
0
1
0
0
0
1
0
1
1
0
1
0
0
0
1
0
1
0
0
1
0
1
0
1
0
0
0
0
0
0
1
0
1
0
0
1
0
1
0
0
0
0
0
1
0
0
0
1
0
0
0
0
1
0
1
1
0
0
1
0
0
1
1
0
0
1
1
0
0
0
1
0
1
0
1
0
0
0
0
0
0
1
1
0
0
1
1
0
0
0
1
0
0
1
0
0
0
0
0
0
0
1
0
0
1
1
1
1
0
0
0
0
0
0
0
0
0
1
0
1
1
0
1
0
0
0
0
1
0
0
0
0
0
0
...

result:

ok 200000 numbers

Test #28:

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

input:

200000 199999
120617 80828
13272 97962
41934 176744
150975 121571
91783 67788
100260 162772
35802 169224
123613 115183
135794 105269
185456 199143
84690 12984
36504 2054
93706 194034
24493 5823
74997 54456
132249 56747
71986 56575
165188 107851
68215 54394
140016 58985
169228 893
191680 179957
11519...

output:

0
0
1
0
0
0
0
1
1
1
1
1
1
0
1
0
1
0
0
1
1
0
1
0
1
1
1
1
0
0
0
0
1
1
0
0
1
1
0
0
1
1
0
0
1
0
0
0
1
1
0
0
0
0
0
1
0
0
0
1
0
0
0
1
0
0
0
0
1
1
1
1
0
0
0
0
0
1
0
0
1
1
0
0
0
0
0
1
0
1
1
1
0
0
0
0
0
0
0
0
0
0
1
1
0
0
0
0
1
1
0
0
0
0
0
0
0
0
0
1
0
0
0
1
0
1
0
1
1
0
0
0
0
0
0
0
0
0
0
1
1
1
0
0
0
0
1
1
0
0
...

result:

ok 200000 numbers

Test #29:

score: 0
Accepted
time: 176ms
memory: 165644kb

input:

200000 199999
80523 78208
52050 185142
45449 167977
90068 106565
43273 190011
16246 112358
81161 158164
13196 57295
56974 26333
126125 15738
171278 159525
81581 54086
126814 36428
173212 72440
191064 31200
106105 40277
154997 92621
171617 174759
67659 76581
183437 41309
65335 105131
139375 152357
79...

output:

1
1
0
0
1
0
0
1
0
1
1
0
1
0
1
1
1
0
0
1
0
0
0
1
1
0
0
0
1
0
0
0
0
1
0
1
0
1
0
1
0
1
0
0
0
0
0
0
0
1
0
0
1
0
1
1
1
1
0
0
0
0
1
0
1
0
1
0
1
0
1
0
0
1
0
0
0
1
1
0
1
0
1
1
0
0
0
0
0
1
0
1
0
0
1
1
0
0
1
1
1
0
0
1
1
0
0
0
1
0
0
0
1
0
1
0
1
0
1
1
0
0
0
1
0
1
0
0
0
1
1
1
0
0
0
0
0
0
0
0
1
1
0
1
1
0
0
0
0
1
...

result:

ok 200000 numbers

Test #30:

score: 0
Accepted
time: 224ms
memory: 191184kb

input:

200000 199999
61382 54455
490 59946
139156 102300
35537 43637
76776 86989
79129 119645
153123 36402
81958 136410
52097 86719
147859 131778
60586 35889
142821 123853
79346 69526
67846 23568
138833 153738
186473 167458
38068 187606
98567 120865
158608 163079
906 27748
153132 32195
149609 171405
198701...

output:

0
0
0
1
0
0
0
1
1
0
0
0
1
0
1
0
0
1
1
1
1
0
1
0
0
0
0
0
1
1
0
0
0
1
0
0
1
0
1
0
0
0
0
0
0
0
1
1
0
1
0
0
0
0
1
0
0
0
0
1
0
1
0
1
1
1
1
0
0
0
0
0
1
0
0
0
0
0
1
1
0
1
0
1
1
0
1
1
1
0
0
1
0
0
0
0
1
1
0
1
0
1
1
0
0
0
1
0
0
0
0
0
0
0
0
1
1
0
0
0
1
1
0
0
0
1
0
1
0
0
0
1
1
0
1
1
1
1
0
1
0
0
1
0
1
0
0
0
1
0
...

result:

ok 200000 numbers