QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#228813#5822. 城市建设Terryjoy10 0ms3704kbC++14894b2023-10-28 14:17:032023-10-28 14:17:04

Judging History

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

  • [2023-10-28 14:17:04]
  • 评测
  • 测评结果:10
  • 用时:0ms
  • 内存:3704kb
  • [2023-10-28 14:17:03]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = a; i <= (b); i++)
#define drep(i, a, b) for (int i = a; i >= (b); i--)
typedef long long ll;
int n, c;
ll ccc(int x) {
	return (1ll * x * x - x % 2) / 4;
}
ll cal(int num) {
	int a = n / num, b = a + 1, cb = n % num, ca = num - cb;
	ll tot;
	if (num == 1)
		tot = 0;
	else {
		tot = n - 1;
		if (cb >= 2) {
			tot -= 2 * (b / 2);
		} else if (cb == 1) {
			tot -= b / 2 + a / 2;
		} else
			tot -= 2 * (a / 2);
	}
	return tot + 1ll * num * c + ccc(a) * ca + ccc(b) * cb;
}

signed main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> c;
	int l = 1, r = n;
	for (int i = 1; i <= 100; ++i) {
		int lm = l + (r - l) / 3, rm = r - (r - l) / 3;
		if (cal(lm) < cal(rm))
			r = rm;
		else
			l = lm;
	}
	ll ans = 1e18;
	ans = min(ans, cal(l));
	cout << ans;
	return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3620kb

input:

14
7

output:

56

result:

wrong answer 1st lines differ - expected: '45', found: '56'

Test #2:

score: 0
Wrong Answer
time: 0ms
memory: 3608kb

input:

15
9

output:

65

result:

wrong answer 1st lines differ - expected: '53', found: '65'

Test #3:

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

input:

15
32

output:

88

result:

ok single line: '88'

Test #4:

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

input:

18
47

output:

128

result:

ok single line: '128'

Test #5:

score: 0
Wrong Answer
time: 0ms
memory: 3636kb

input:

691
13

output:

3155

result:

wrong answer 1st lines differ - expected: '3152', found: '3155'

Test #6:

score: 0
Wrong Answer
time: 0ms
memory: 3616kb

input:

723
381

output:

14843

result:

wrong answer 1st lines differ - expected: '14800', found: '14843'

Test #7:

score: 0
Wrong Answer
time: 0ms
memory: 3548kb

input:

530
4577

output:

37492

result:

wrong answer 1st lines differ - expected: '36261', found: '37492'

Test #8:

score: 0
Wrong Answer
time: 0ms
memory: 3548kb

input:

873
71661

output:

262193

result:

wrong answer 1st lines differ - expected: '239024', found: '262193'

Test #9:

score: 0
Wrong Answer
time: 0ms
memory: 3552kb

input:

50512
6380

output:

4084991

result:

wrong answer 1st lines differ - expected: '4084971', found: '4084991'

Test #10:

score: 0
Wrong Answer
time: 0ms
memory: 3636kb

input:

94371
8943

output:

9018589

result:

wrong answer 1st lines differ - expected: '9018507', found: '9018589'

Test #11:

score: 0
Wrong Answer
time: 0ms
memory: 3704kb

input:

51969
2391

output:

2593011

result:

wrong answer 1st lines differ - expected: '2593001', found: '2593011'

Test #12:

score: 0
Wrong Answer
time: 0ms
memory: 3704kb

input:

90967
8394

output:

8425026

result:

wrong answer 1st lines differ - expected: '8424956', found: '8425026'

Test #13:

score: 0
Wrong Answer
time: 0ms
memory: 3576kb

input:

903367404
61

output:

7949633143

result:

wrong answer 1st lines differ - expected: '7949633140', found: '7949633143'

Test #14:

score: 0
Wrong Answer
time: 0ms
memory: 3680kb

input:

619459664
4190

output:

40716267273

result:

wrong answer 1st lines differ - expected: '40716267253', found: '40716267273'

Test #15:

score: 0
Wrong Answer
time: 0ms
memory: 3704kb

input:

714829312
304390

output:

395097112567

result:

wrong answer 1st lines differ - expected: '395097112253', found: '395097112567'

Test #16:

score: 0
Wrong Answer
time: 0ms
memory: 3628kb

input:

760183494
45248537

output:

5114288966217

result:

wrong answer 1st lines differ - expected: '5114288962225', found: '5114288966217'

Test #17:

score: 0
Wrong Answer
time: 0ms
memory: 3628kb

input:

500350887
499

output:

11674854001

result:

wrong answer 1st lines differ - expected: '11674853991', found: '11674854001'

Test #18:

score: 0
Wrong Answer
time: 0ms
memory: 3640kb

input:

837064072
96455

output:

260805440993

result:

wrong answer 1st lines differ - expected: '260805440727', found: '260805440993'

Test #19:

score: 0
Wrong Answer
time: 0ms
memory: 3616kb

input:

784256648
6177252

output:

1949981818443

result:

wrong answer 1st lines differ - expected: '1949981815499', found: '1949981818443'

Test #20:

score: 0
Wrong Answer
time: 0ms
memory: 3624kb

input:

650371022
480071734

output:

14250630260881

result:

wrong answer 1st lines differ - expected: '14250630194974', found: '14250630260881'