QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#395848#6749. TargetpotremzWA 0ms3956kbC++17795b2024-04-21 21:11:102024-04-21 21:11:11

Judging History

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

  • [2024-04-21 21:11:11]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3956kb
  • [2024-04-21 21:11:10]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const double eps = 1e-4;
double a, b;
map<double, int>cnt;
bool have_answer;
void dfs(double x, string ans) {
	if (have_answer) {
		return;
	}
	if (cnt.count(x)) {
		if (cnt[x] < ans.size()) {
			return;
		} else {
			cnt[x] = ans.size();
		}
	}
	if (ans.size() > 50) {
		return;
	}
	if (fabs(x - b) <= eps) {
		have_answer = 1;
		cout << ans;
		return;
	}
	if (x > b) {
		cnt[x / 2] = ans.size() + 1;
		dfs(x / 2, ans + '1');
		if (have_answer) {
			return;
		}
	} else {
		cnt[(x + 1) / 2] = ans.size() + 1;
		dfs((x + 1) / 2, ans + '2');
		if (have_answer) {
			return;
		}
	}
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin >> a >> b;
	string ans = "";
	dfs(a, ans);
	return 0;
}

详细

Test #1:

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

input:

0.5 0.25

output:

1

result:

ok ok

Test #2:

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

input:

1 0.75

output:

12

result:

ok ok

Test #3:

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

input:

1 0

output:

11111111111111

result:

ok ok

Test #4:

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

input:

0.361954 0.578805

output:


result:

wrong answer wa