QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#368334#4366. Forever Youngcciafrino#WA 2ms3776kbC++201.2kb2024-03-27 01:01:102024-03-27 01:01:11

Judging History

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

  • [2024-03-27 01:01:11]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3776kb
  • [2024-03-27 01:01:10]
  • 提交

answer

#include<bits/stdc++.h>

int main() {
	using namespace std;
	cin.tie(nullptr)->sync_with_stdio(false);
	using i64 = int64_t;
	i64 N, L; cin >> N >> L;

	i64 ans = 0;

	auto test = [&](i64 B) -> int64_t {
		i64 cur = N;
		i64 val = 0;
		vector<int> digs;

		while (cur) {
			if (cur % B >= 10) return -1;
			digs.push_back(cur % B);
			cur /= B;
		}

		int cnt = int(digs.size());
		bool ok = false;
		if (cnt <= 10) {
			for (int d = cnt-1; d >= 0; --d) {
				val = 10 * val + digs[d];
			}
			if (val >= L) ok = true;
		} else ok = true;
		
		return ok ? B : -1;
	};

	auto check = [&](i64 m, i64 x, i64 y, i64 d) -> bool {
		return (m * m * d + m * x + y < N);
	};

	for (int x = 2; x <= 5e5; ++x) ans = max(ans, test(x));

	for (int x = 1; x <= 9; ++x) {
		for (int y = 0; y <= 9; ++y) {
			i64 K = (N - y)/x;
			ans = max(ans, test(K));
		}
	}
	
	for (int d = 1; d <= 9; ++d) {
		for (int x = 0; x <= 9; ++x) {
			for (int y = 0; y <= 9; ++y) {

				i64 mi = 2, ma = 1e9;
				while (ma - mi > 1) {
					i64 md = (mi + ma) / 2;
					(check(md, x, y, d) ? mi = md : ma = md);
				}

				ans = max(ans, test(mi));
			}
		}
	}

	cout << ans << '\n';
}

详细

Test #1:

score: 100
Accepted
time: 2ms
memory: 3524kb

input:

32 20

output:

16

result:

ok single line: '16'

Test #2:

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

input:

2016 100

output:

42

result:

ok single line: '42'

Test #3:

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

input:

1000000000000000000 10

output:

1000000000000000000

result:

ok single line: '1000000000000000000'

Test #4:

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

input:

149239876439186 470

output:

11

result:

ok single line: '11'

Test #5:

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

input:

4851495 95

output:

539054

result:

ok single line: '539054'

Test #6:

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

input:

19839853985 19839853985

output:

10

result:

ok single line: '10'

Test #7:

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

input:

1000000000000000000 17

output:

999999999999999993

result:

ok single line: '999999999999999993'

Test #8:

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

input:

1000000000000000000 23

output:

499999999999999998

result:

ok single line: '499999999999999998'

Test #9:

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

input:

1000000000000000000 58

output:

166666666666666666

result:

ok single line: '166666666666666666'

Test #10:

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

input:

1000000000000000000 145

output:

999999997

result:

ok single line: '999999997'

Test #11:

score: -100
Wrong Answer
time: 0ms
memory: 3512kb

input:

1000000000000000000 230

output:

499999999

result:

wrong answer 1st lines differ - expected: '500000000', found: '499999999'