QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#291060#2862. 龙与地下城MoRanSky100 ✓442ms4160kbC++232.0kb2023-12-26 04:40:112023-12-26 04:40:12

Judging History

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

  • [2023-12-26 04:40:12]
  • 评测
  • 测评结果:100
  • 用时:442ms
  • 内存:4160kb
  • [2023-12-26 04:40:11]
  • 提交

answer

// Skyqwq
#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

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

template <typename T> void inline read(T &x) {
	x = 0; int f = 1; char s = getchar();
	while (s < '0' || s > '9') { if (s == '-') { f = -1; } s = getchar(); }
	while (s >= '0' && s <= '9') x = x * 10 + (s ^ 48), s = getchar();
	x *= f;
}

template <typename T> bool inline chkMin(T &x, T y) { return y < x ? x = y, 1 : 0; }
template <typename T> bool inline chkMax(T &x, T y) { return y > x ? x = y, 1 : 0; }

int X, Y;

const double PI = acos(-1);

double u, o, Z, W;

double f(double x) {
	return Z * exp((x - u) * (x - u) * W);
}

double get(double l, double r) {
	double mid = (l + r) / 2;
	double vl = f(l), vmid = f(mid), vr = f(r);
	return (vl + vmid * 4 + vr) / 6 * (r - l);
}

const double eps = 1e-6;

double inline calc(double l, double r) {
//	cerr << l << " ???" << r << endl;
	double mid = (l + r) / 2;
	double w = get(l, r), o = get(l, mid) + get(mid, r);
	if (r - l < 1 && fabs(o - w) < eps) return w;
	return calc(l, mid) + calc(mid, r);
}

const int N = 16005;

double h[N];

void inline baoli() {
	h[0] = 1;
	int s = 0;
	for (int i = 1; i <= Y; i++) {
		for (int j = s; j >= 0; j--) {
			for (int k = 1; k < X; k++)
				h[j + k] += h[j] / X;
			h[j] /= X;
		}
		s += X - 1;
	}
	for (int i = 0; i < 10; i++) {
		int A, B;
		read(A), read(B);
		double ret = 0;
		for (int j = A; j <= B; j++) ret += h[j];
		printf("%.12lf\n", ret);
	}
	for (int i = 0; i <= s; i++) h[i] = 0;
}

int main() {
	int T; read(T);
	while (T--) {
		read(X), read(Y);
		if (Y <= 800) {
			baoli();
		} else {
			u = (X - 1.0) / 2 * Y, o = (X * X - 1) / 12.0 * Y;
			Z = 1 / sqrt(2 * PI * o);
			W = -1 / (2 * o);
			for (int i = 0; i < 10; i++) {
				int A, B;
				read(A), read(B);
				printf("%.12lf\n", calc(A, B));
			}
		}
	}	
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 5
Accepted
time: 0ms
memory: 3836kb

input:

10
14 6
41 53
19 47
7 49
1 28
11 33
12 44
13 40
49 76
28 67
30 50
5 10
26 31
1 23
16 34
22 31
2 23
13 21
19 26
19 34
16 26
15 28
13 3
10 33
10 35
8 18
13 28
16 26
13 21
21 33
10 13
11 33
13 21
4 11
0 13
4 19
9 13
12 18
4 13
9 19
13 17
13 27
20 25
20 25
17 3
0 34
6 20
12 28
13 24
2 24
16 23
0 34
22 3...

output:

0.368639183078
0.783005221039
0.852144541178
0.147732609287
0.292042564110
0.705250230559
0.556417155054
0.172344484441
0.873460462902
0.702178593741
0.106662195200
0.780493721600
0.840337100800
0.366217420800
0.780492697600
0.582988697600
0.555932569600
0.629288140800
0.766981529600
0.861181235200
...

result:

ok  (10 test cases)

Test #2:

score: 5
Accepted
time: 19ms
memory: 3964kb

input:

10
4 1
0 1
1 2
0 1
1 1
0 0
0 1
1 2
0 1
0 0
2 2
15 2
0 8
7 17
0 15
10 27
14 25
8 24
8 17
6 13
7 13
10 17
9 3
2 6
8 19
10 17
10 16
0 15
9 10
1 8
8 14
14 23
6 15
3 49
44 76
56 74
54 78
51 69
22 49
35 43
24 51
44 57
54 68
52 65
13 49
174 298
228 289
242 310
139 282
256 276
301 397
285 370
251 282
259 33...

output:

0.500000000000
0.500000000000
0.500000000000
0.250000000000
0.250000000000
0.500000000000
0.500000000000
0.500000000000
0.250000000000
0.250000000000
0.200000000000
0.582222222222
0.595555555556
0.751111111111
0.506666666667
0.795555555556
0.546666666667
0.373333333333
0.342222222222
0.462222222222
...

result:

ok  (10 test cases)

Test #3:

score: 5
Accepted
time: 26ms
memory: 4068kb

input:

10
3 1
1 1
0 0
0 1
0 1
0 0
0 0
0 0
1 1
0 1
1 1
14 8
47 97
40 103
1 43
40 44
46 50
9 37
36 73
39 103
42 97
14 58
17 2
14 23
10 26
20 26
9 26
4 13
0 11
11 28
7 14
16 23
17 20
15 31
188 331
219 229
238 253
187 356
105 197
91 220
223 269
185 251
120 225
229 298
6 26
69 98
52 59
47 71
26 75
60 91
57 102
...

output:

0.333333333333
0.333333333333
0.666666666667
0.666666666667
0.333333333333
0.333333333333
0.333333333333
0.333333333333
0.666666666667
0.333333333333
0.682239618804
0.860752088407
0.231487810274
0.119529507475
0.161059528144
0.103748706075
0.895735426161
0.879378669142
0.818136455269
0.712281999739
...

result:

ok  (10 test cases)

Test #4:

score: 5
Accepted
time: 29ms
memory: 4060kb

input:

10
17 1
1 13
8 12
0 1
4 5
3 5
13 15
5 7
1 2
1 15
1 12
18 2
20 23
3 14
5 14
15 30
9 22
8 12
8 31
3 24
11 27
6 26
18 7
55 117
54 110
61 86
32 59
64 72
41 59
14 69
4 58
43 107
42 71
14 71
434 466
430 572
274 467
336 465
278 431
368 492
336 425
258 422
471 498
452 624
15 43
272 408
219 331
220 287
280 3...

output:

0.764705882353
0.294117647059
0.117647058824
0.117647058824
0.176470588235
0.176470588235
0.176470588235
0.117647058824
0.882352941176
0.705882352941
0.166666666667
0.351851851852
0.324074074074
0.598765432099
0.620370370370
0.169753086420
0.870370370370
0.811728395062
0.709876543210
0.824074074074
...

result:

ok  (10 test cases)

Test #5:

score: 5
Accepted
time: 32ms
memory: 3928kb

input:

10
14 1
1 3
1 7
0 9
8 9
6 10
1 3
6 11
10 12
6 10
0 7
14 8
26 42
2 38
24 54
35 52
55 96
14 43
45 91
61 77
40 68
43 52
20 8
77 150
11 67
3 60
66 108
64 83
59 80
46 62
58 130
45 57
13 77
12 35
181 308
215 249
72 212
202 303
166 203
171 254
210 239
195 301
219 267
109 198
17 63
492 608
451 561
410 530
5...

output:

0.214285714286
0.500000000000
0.714285714286
0.142857142857
0.357142857143
0.214285714286
0.428571428571
0.214285714286
0.357142857143
0.571428571429
0.196823477460
0.120621324082
0.579982441610
0.453974668857
0.414799549781
0.231349925392
0.741137223882
0.219867963298
0.785638689545
0.311339104415
...

result:

ok  (10 test cases)

Test #6:

score: 5
Accepted
time: 30ms
memory: 4124kb

input:

10
16 1
5 10
0 12
2 14
2 8
10 12
5 10
6 13
1 6
6 11
10 14
9 8
2 36
19 36
18 41
23 45
23 46
33 52
9 30
3 30
16 29
23 32
4 7
1 8
1 12
9 18
2 8
14 17
8 12
6 14
5 9
10 20
11 17
12 63
349 510
338 389
264 315
325 435
326 345
344 470
314 459
318 508
329 507
230 344
2 34
14 25
20 32
18 29
7 15
17 22
17 29
7...

output:

0.375000000000
0.812500000000
0.812500000000
0.437500000000
0.187500000000
0.375000000000
0.500000000000
0.375000000000
0.375000000000
0.312500000000
0.727778266781
0.696003163632
0.878794949330
0.869753424425
0.878794949330
0.471467408633
0.419808561028
0.420106493129
0.357533991962
0.428313877844
...

result:

ok  (10 test cases)

Test #7:

score: 5
Accepted
time: 42ms
memory: 4156kb

input:

10
12 1
1 4
4 8
3 7
3 10
2 5
3 9
2 9
0 1
0 3
1 8
4 3
0 2
3 5
3 5
1 6
5 6
4 4
5 6
6 6
1 4
6 8
5 6
10 16
9 19
9 14
8 21
0 14
8 19
5 12
9 17
14 18
3 12
7 77
241 271
137 228
203 249
234 306
212 287
137 237
186 213
206 252
228 337
232 252
6 36
82 140
31 87
86 149
80 99
67 100
74 82
97 148
37 88
54 91
103...

output:

0.333333333333
0.416666666667
0.416666666667
0.666666666667
0.333333333333
0.583333333333
0.666666666667
0.166666666667
0.333333333333
0.666666666667
0.156250000000
0.531250000000
0.531250000000
0.828125000000
0.343750000000
0.187500000000
0.343750000000
0.156250000000
0.484375000000
0.296875000000
...

result:

ok  (10 test cases)

Test #8:

score: 5
Accepted
time: 24ms
memory: 4152kb

input:

10
9 1
0 6
1 7
0 4
0 2
2 6
2 2
0 1
1 6
1 7
4 5
4 2
1 4
5 5
0 4
1 4
4 5
2 5
5 5
3 3
1 4
2 3
5 8
18 29
14 21
8 20
17 24
17 31
14 21
5 16
17 22
15 19
17 26
8 32
120 151
47 109
98 134
68 102
127 161
58 111
89 101
59 128
97 128
48 115
11 71
355 487
350 429
284 323
337 469
345 403
330 392
329 473
232 326
...

output:

0.777777777778
0.777777777778
0.555555555556
0.333333333333
0.555555555556
0.111111111111
0.222222222222
0.666666666667
0.777777777778
0.222222222222
0.750000000000
0.125000000000
0.812500000000
0.750000000000
0.312500000000
0.750000000000
0.125000000000
0.250000000000
0.750000000000
0.437500000000
...

result:

ok  (10 test cases)

Test #9:

score: 5
Accepted
time: 16ms
memory: 3984kb

input:

10
11 1
0 2
0 7
0 5
2 9
3 8
6 8
5 6
1 2
4 9
3 8
13 4
19 29
2 31
3 24
17 26
2 23
27 32
30 39
6 15
15 26
23 46
2 4
1 2
0 2
2 3
1 3
1 1
0 2
3 3
1 2
2 3
2 2
8 49
104 181
90 175
146 162
77 190
190 263
164 192
147 183
153 181
129 169
165 201
2 46
6 26
23 27
25 39
25 28
27 39
18 26
15 21
15 23
20 23
3 22
3...

output:

0.272727272727
0.727272727273
0.545454545455
0.727272727273
0.545454545455
0.272727272727
0.181818181818
0.181818181818
0.545454545455
0.545454545455
0.523055915409
0.835089807780
0.525191694969
0.461678512657
0.474108049438
0.239977591821
0.221140716361
0.129197156962
0.519974790799
0.576520429957
...

result:

ok  (10 test cases)

Test #10:

score: 5
Accepted
time: 32ms
memory: 3956kb

input:

10
14 1
4 10
1 8
6 7
0 7
4 10
0 2
2 8
3 5
4 8
3 4
8 3
4 6
12 14
1 8
11 20
14 20
4 14
7 18
4 6
4 14
5 10
6 4
9 18
3 14
7 10
11 11
2 6
5 15
7 13
4 14
3 6
2 10
2 52
31 42
18 23
27 32
31 45
20 30
31 39
22 41
22 45
24 38
23 25
15 55
384 442
323 411
405 418
264 382
415 483
403 535
360 413
422 581
375 528
...

output:

0.500000000000
0.571428571429
0.142857142857
0.571428571429
0.500000000000
0.214285714286
0.500000000000
0.214285714286
0.357142857143
0.142857142857
0.125000000000
0.242187500000
0.314453125000
0.498046875000
0.232421875000
0.796875000000
0.816406250000
0.125000000000
0.796875000000
0.431640625000
...

result:

ok  (10 test cases)

Test #11:

score: 5
Accepted
time: 2ms
memory: 4076kb

input:

10
2 1
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
2 4
2 2
1 1
1 3
1 1
1 1
2 2
0 1
0 2
2 3
0 1
2 2
0 0
0 0
1 1
0 1
1 1
1 1
0 1
0 0
0 1
0 0
2 75
43 54
20 40
16 32
26 41
21 32
39 62
35 47
35 39
33 45
33 38
2 45
20 23
12 24
10 18
10 22
12 20
12 18
23 41
20 26
8 22
4 23
2 652
295 341
298 332
339 354
291 318...

output:

0.500000000000
0.500000000000
0.500000000000
0.500000000000
0.500000000000
0.500000000000
0.500000000000
0.500000000000
0.500000000000
0.500000000000
0.375000000000
0.250000000000
0.875000000000
0.250000000000
0.250000000000
0.375000000000
0.312500000000
0.687500000000
0.625000000000
0.312500000000
...

result:

ok  (10 test cases)

Test #12:

score: 5
Accepted
time: 2ms
memory: 3980kb

input:

10
2 1
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
2 6
4 5
2 5
0 4
0 2
0 2
4 5
3 5
0 3
0 3
3 4
2 8
0 4
4 4
0 2
1 5
3 6
2 2
4 7
1 5
0 5
4 5
2 53
24 28
12 25
28 28
23 44
23 43
16 23
26 32
26 28
27 45
18 24
2 60
34 50
8 28
16 32
27 46
35 40
9 33
29 46
20 29
15 33
30 34
2 303
148 159
149 186
157 172
154 166...

output:

0.500000000000
0.500000000000
0.500000000000
0.500000000000
0.500000000000
0.500000000000
0.500000000000
0.500000000000
0.500000000000
0.500000000000
0.328125000000
0.875000000000
0.890625000000
0.343750000000
0.343750000000
0.328125000000
0.640625000000
0.656250000000
0.656250000000
0.546875000000
...

result:

ok  (10 test cases)

Test #13:

score: 5
Accepted
time: 13ms
memory: 4036kb

input:

10
13 1
7 10
5 11
2 8
5 11
6 9
5 9
3 4
6 7
2 5
3 10
5 8
15 17
12 24
18 19
15 29
6 16
2 11
18 31
17 27
19 20
13 31
14 3
15 30
23 26
1 27
12 20
16 36
9 19
16 23
21 28
1 18
22 35
17 71
377 612
584 609
524 781
485 529
496 609
528 560
572 664
424 611
615 718
545 645
11 80
299 392
265 374
387 420
253 433
...

output:

0.307692307692
0.538461538462
0.538461538462
0.538461538462
0.307692307692
0.384615384615
0.153846153846
0.153846153846
0.307692307692
0.615384615385
0.287552000000
0.851814400000
0.162304000000
0.643660800000
0.545576960000
0.132610560000
0.356221440000
0.449881600000
0.136550400000
0.806077440000
...

result:

ok  (10 test cases)

Test #14:

score: 5
Accepted
time: 48ms
memory: 3960kb

input:

10
15 1
1 6
3 4
6 12
2 12
6 8
1 12
8 12
7 13
5 7
0 6
2 6
3 4
1 2
1 4
1 3
0 1
2 3
0 4
1 4
3 4
0 3
13 2
2 10
14 17
16 21
15 20
7 23
14 15
8 9
12 22
2 14
8 13
10 45
198 253
200 301
189 303
190 227
176 188
203 270
183 245
200 316
226 262
109 213
17 63
304 538
450 563
398 515
517 623
328 491
535 676
374 ...

output:

0.400000000000
0.133333333333
0.466666666667
0.733333333333
0.200000000000
0.800000000000
0.333333333333
0.466666666667
0.200000000000
0.466666666667
0.546875000000
0.328125000000
0.875000000000
0.640625000000
0.109375000000
0.546875000000
0.890625000000
0.875000000000
0.546875000000
0.656250000000
...

result:

ok  (10 test cases)

Test #15:

score: 5
Accepted
time: 14ms
memory: 4040kb

input:

10
4 1
0 1
0 1
0 2
1 2
0 1
1 2
1 1
0 1
0 0
0 2
20 6
56 79
10 66
64 84
43 83
51 95
0 74
50 55
16 69
47 82
34 76
12 6
18 26
29 58
3 31
14 35
22 39
39 62
33 52
14 43
30 45
27 36
3 25
25 32
22 44
23 31
23 34
30 37
6 22
28 31
7 29
6 20
27 46
3 74
62 78
66 96
38 72
57 70
68 88
61 68
54 73
31 82
42 75
44 7...

output:

0.500000000000
0.500000000000
0.750000000000
0.500000000000
0.500000000000
0.500000000000
0.250000000000
0.500000000000
0.250000000000
0.750000000000
0.484893375000
0.744643484375
0.301698031250
0.813886937500
0.671306250000
0.889336562500
0.156800218750
0.806477125000
0.731472562500
0.865771828125
...

result:

ok  (10 test cases)

Test #16:

score: 5
Accepted
time: 51ms
memory: 4084kb

input:

10
6 1
0 2
2 2
2 3
1 2
2 4
1 4
2 4
0 0
0 1
3 4
17 6
10 40
30 44
31 54
18 34
8 63
29 47
33 58
1 41
44 54
21 50
13 6
35 38
34 45
27 68
22 47
31 56
36 66
16 38
45 52
34 45
19 28
14 27
133 188
157 258
118 172
154 276
202 253
161 268
183 211
115 162
158 252
157 212
19 42
349 590
219 386
314 410
391 509
2...

output:

0.500000000000
0.166666666667
0.333333333333
0.333333333333
0.500000000000
0.666666666667
0.500000000000
0.166666666667
0.333333333333
0.333333333333
0.270348434840
0.325369800082
0.627731235072
0.129746786016
0.899044804388
0.431156095297
0.703721986253
0.298317614338
0.344490656868
0.570984053945
...

result:

ok  (10 test cases)

Test #17:

score: 5
Accepted
time: 442ms
memory: 4152kb

input:

10
3 1
0 1
1 2
0 0
0 0
0 1
0 0
0 1
0 1
0 0
0 1
14 3
0 30
30 39
0 23
17 21
22 36
15 29
14 22
11 38
11 17
16 20
20 6
0 91
91 114
19 73
63 72
5 49
53 84
53 72
23 61
25 43
23 60
5 35
0 112
112 140
50 71
36 59
71 110
60 91
77 80
20 60
69 106
63 65
4 38
0 91
91 114
41 61
55 80
34 60
21 59
16 53
49 80
39 6...

output:

0.666666666667
0.666666666667
0.333333333333
0.333333333333
0.666666666667
0.333333333333
0.666666666667
0.666666666667
0.333333333333
0.666666666667
0.939868804665
0.080174927114
0.706997084548
0.264212827988
0.389941690962
0.673104956268
0.453717201166
0.895408163265
0.289358600583
0.260568513120
...

result:

ok  (10 test cases)

Test #18:

score: 5
Accepted
time: 423ms
memory: 4160kb

input:

10
20 1
0 14
14 19
0 5
1 16
9 13
1 6
7 12
2 14
7 14
5 13
12 6
0 52
52 66
14 35
35 41
29 42
12 36
25 50
36 43
6 23
39 45
10 5
0 35
35 45
17 44
16 36
18 41
1 22
22 23
3 20
21 36
0 24
5 28
0 89
89 112
50 65
47 89
54 64
56 60
57 65
18 53
38 54
50 86
7 42
0 201
201 252
120 147
59 135
108 143
60 142
120 1...

output:

0.750000000000
0.300000000000
0.300000000000
0.800000000000
0.250000000000
0.300000000000
0.300000000000
0.650000000000
0.400000000000
0.450000000000
0.990927613812
0.012924382716
0.604429896476
0.269766348380
0.564250846622
0.652783136145
0.820439091435
0.276419431584
0.134060329861
0.191237461420
...

result:

ok  (10 test cases)

Test #19:

score: 5
Accepted
time: 397ms
memory: 4092kb

input:

10
19 1
0 14
14 18
4 5
5 8
2 12
0 15
7 14
7 9
1 17
0 5
11 5
0 40
40 50
30 37
34 43
10 28
7 23
3 24
30 49
7 19
10 18
11 7
0 56
56 70
27 39
46 61
1 31
3 34
40 53
25 48
35 68
44 48
9 70
0 448
448 560
300 371
274 303
272 289
297 380
278 331
220 299
243 309
245 301
17 64
0 819
819 1024
435 535
504 748
50...

output:

0.789473684211
0.263157894737
0.105263157895
0.210526315789
0.578947368421
0.842105263158
0.421052631579
0.157894736842
0.894736842105
0.315789473684
0.987569155112
0.018646267331
0.229504939429
0.115659014846
0.672358445461
0.415632315229
0.472545963701
0.267735065290
0.221091455502
0.171914486715
...

result:

ok  (10 test cases)

Test #20:

score: 5
Accepted
time: 440ms
memory: 3944kb

input:

10
15 1
0 11
11 14
4 6
3 10
4 13
2 12
2 10
5 6
0 6
8 13
10 8
0 57
57 72
21 35
6 26
40 58
7 30
29 36
28 39
22 43
26 55
13 7
0 67
67 84
13 42
28 57
1 51
50 76
47 52
45 62
4 50
32 51
9 54
0 345
345 432
188 201
194 241
198 212
221 303
203 235
216 228
197 305
143 192
3 31
0 49
49 62
8 33
24 30
28 36
29 5...

output:

0.800000000000
0.266666666667
0.200000000000
0.533333333333
0.666666666667
0.733333333333
0.600000000000
0.133333333333
0.466666666667
0.400000000000
0.996841900000
0.004800180000
0.448339160000
0.123552330000
0.334037550000
0.252608170000
0.342855150000
0.513306750000
0.781897590000
0.892908730000
...

result:

ok  (10 test cases)