QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#412308 | #6749. Target | XiaoretaW# | TL | 1ms | 3832kb | C++14 | 636b | 2024-05-16 11:41:15 | 2024-05-16 11:41:16 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const double eps = 1e-6;
int main() {
double a, b; cin >> a >> b;
string ans = "";
if (b <= eps) {
while (a > eps) {
ans += '1';
a /= 2.0;
}
} else {
while (abs(b - a) > eps) {
if (b - 0.5 >= eps) {
b = (b - 0.5) * 2.0;
ans += '2';
} else {
b = b * 2.0;
ans += '1';
}
}
reverse(ans.begin(), ans.end());
}
cout << ans << '\n';
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3776kb
input:
0.5 0.25
output:
1
result:
ok ok
Test #2:
score: 0
Accepted
time: 0ms
memory: 3832kb
input:
1 0.75
output:
12
result:
ok ok
Test #3:
score: 0
Accepted
time: 0ms
memory: 3704kb
input:
1 0
output:
11111111111111111111
result:
ok ok
Test #4:
score: -100
Time Limit Exceeded
input:
0.361954 0.578805