QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#395848 | #6749. Target | potremz | WA | 0ms | 3956kb | C++17 | 795b | 2024-04-21 21:11:10 | 2024-04-21 21:11:11 |
Judging History
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;
}
Details
Tip: Click on the bar to expand more detailed information
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