QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#762234#8027. Sky GardenraywuAC ✓1ms3960kbC++141.5kb2024-11-19 14:14:342024-11-19 14:14:36

Judging History

This is the latest submission verdict.

  • [2024-11-19 14:14:36]
  • Judged
  • Verdict: AC
  • Time: 1ms
  • Memory: 3960kb
  • [2024-11-19 14:14:34]
  • Submitted

answer

#include <bits/stdc++.h>
#define _for(i, a, b)  for (int i = (a); i <= (b); i ++ )
#define _all(i, a, b)  for (int i = (a); i >= (b); i -- )
#define int long long
#define ll long long
#define ld long double
using namespace std;
const int N = 1e7 + 5; const ld pi = acos( - 1);
int n, m, t, k; ld tmp, ans1, ans2, inv_m, res, res1, res2;
inline void Add(ld & x, ld y) { x = x + y; }
inline void Mul(ld & x, ld y) { x *= y; }
inline ld pw(ld a, int b) {
	ld res = 1;
	while (b) {
		if (b & 1)  Mul(res, a);
		Mul(a, a), b >>= 1;
	}
	return res;
}
signed main() {
	ios :: sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> m; ld inv_m = 1.0 / m, inv_2 = 0.5;
	if (m == 1) {
		_for (i, - n,n)  if (i)  _for (j, i + 1, n)  if (j)  res += j - i;
		return cout << fixed << setprecision(6) << res << "\n", 0;
	}
	_for (i, 1, 2 * n)  Add(res, 1ll * i * (2 * n - i + 1));
	int l = 1, r = m, mid; Add(ans2, 1ll * res * m );
	while (l <= r) {
		mid = (l + r) >> 1;
		if (0.5 / m * mid <= 1.0 / pi)  t = mid, l = mid + 1;
		else  r = mid - 1;
	}
	_for (i, 1, n)  k = n - i, tmp = 1ll * k * (k + 1)  * inv_2 , Add(res1, 2ll * i * t  * (t + 1)  * inv_m  * k ), Add(res2, 2ll * (m - 1) * tmp ), Add(res2, 4ll * (m - t - 1) * i  * k );
	Add(ans1, 1ll * res1 * m ), Add(ans2, 2ll * res2 * m ), res1 = res2 = 0;
	_for (i, 1, n)  Add(res1, 1ll * i * t  * (t + 1)  * inv_m ), Add(res2, 4ll * (m - t - 1) * i );
	Add(ans1, 1ll * res1 * m ), Add(ans2, 1ll * res2 * m ), cout << fixed << setprecision(6) << ans1 * pi + ans2 << "\n";
	return 0;
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3920kb

input:

1 2

output:

14.283185

result:

ok found '14.2831850', expected '14.2831853', error '0.0000000'

Test #2:

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

input:

1 1

output:

2.000000

result:

ok found '2.0000000', expected '2.0000000', error '0.0000000'

Test #3:

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

input:

500 1

output:

166916500.000000

result:

ok found '166916500.0000000', expected '166916500.0000000', error '0.0000000'

Test #4:

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

input:

500 2

output:

763585309.561322

result:

ok found '763585309.5613220', expected '763585309.5613225', error '0.0000000'

Test #5:

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

input:

500 499

output:

49125277129819.335503

result:

ok found '49125277129819.3359375', expected '49125277129819.2734375', error '0.0000000'

Test #6:

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

input:

500 500

output:

49322369986259.837425

result:

ok found '49322369986259.8359375', expected '49322369986259.6953125', error '0.0000000'

Test #7:

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

input:

252 139

output:

488838606007.179469

result:

ok found '488838606007.1794434', expected '488838606007.1795654', error '0.0000000'

Test #8:

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

input:

96 359

output:

181277190205.037121

result:

ok found '181277190205.0371094', expected '181277190205.0371094', error '0.0000000'

Test #9:

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

input:

237 487

output:

4992630041184.196107

result:

ok found '4992630041184.1962891', expected '4992630041184.1953125', error '0.0000000'

Test #10:

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

input:

81 411

output:

142953582310.277363

result:

ok found '142953582310.2773743', expected '142953582310.2773743', error '0.0000000'

Test #11:

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

input:

221 39

output:

25968641931.529713

result:

ok found '25968641931.5297127', expected '25968641931.5297089', error '0.0000000'

Test #12:

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

input:

270 259

output:

2087014641700.021324

result:

ok found '2087014641700.0212402', expected '2087014641700.0227051', error '0.0000000'

Test #13:

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

input:

422 387

output:

17770193032349.623600

result:

ok found '17770193032349.6250000', expected '17770193032349.6250000', error '0.0000000'

Test #14:

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

input:

63 15

output:

89852047.508517

result:

ok found '89852047.5085170', expected '89852047.5085171', error '0.0000000'

Test #15:

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

input:

407 439

output:

20515296102923.205532

result:

ok found '20515296102923.2070312', expected '20515296102923.2070312', error '0.0000000'

Test #16:

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

input:

18 18

output:

3123573.695648

result:

ok found '3123573.6956480', expected '3123573.6956476', error '0.0000000'

Test #17:

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

input:

171 146

output:

168786179167.019313

result:

ok found '168786179167.0193176', expected '168786179167.0194092', error '0.0000000'

Test #18:

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

input:

311 70

output:

232875509505.274827

result:

ok found '232875509505.2748413', expected '232875509505.2748413', error '0.0000000'

Test #19:

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

input:

155 494

output:

1439825967582.998717

result:

ok found '1439825967582.9987793', expected '1439825967582.9992676', error '0.0000000'

Test #20:

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

input:

204 418

output:

2347066265474.488268

result:

ok found '2347066265474.4882812', expected '2347066265474.4873047', error '0.0000000'

Test #21:

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

input:

344 46

output:

136054690372.271500

result:

ok found '136054690372.2714996', expected '136054690372.2714844', error '0.0000000'

Test #22:

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

input:

188 174

output:

318429902145.042022

result:

ok found '318429902145.0419922', expected '318429902145.0420532', error '0.0000000'

Test #23:

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

input:

137 394

output:

632896487876.031428

result:

ok found '632896487876.0313721', expected '632896487876.0313721', error '0.0000000'

Test #24:

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

input:

481 22

output:

85020954588.203103

result:

ok found '85020954588.2031097', expected '85020954588.2031097', error '0.0000000'

Test #25:

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

input:

30 446

output:

8705279441.352085

result:

ok found '8705279441.3520851', expected '8705279441.3520851', error '0.0000000'

Test #26:

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

input:

204 440

output:

2600626525627.956639

result:

ok found '2600626525627.9565430', expected '2600626525627.9575195', error '0.0000000'

Test #27:

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

input:

2 3

output:

175.415927

result:

ok found '175.4159270', expected '175.4159265', error '0.0000000'

Extra Test:

score: 0
Extra Test Passed