QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#372454 | #6749. Target | Qian# | TL | 1ms | 3688kb | C++14 | 847b | 2024-03-31 13:42:35 | 2024-03-31 13:42:36 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define dd double
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define pii pair<int, int>
const int N = 1e6 + 10;
int n, a[N],b[N];
int sum[N];
void solve()
{
vector<ll> ans;
dd a, b;
cin >> a >> b;
while (fabs(a - b) > 1e-4)
{
if (b < 0.5)
{
ans.push_back(1);
b *= 2;
} else if (b == 0.5)
{
if (fabs(a) <= 1e-4)
{
ans.push_back(2);
b = 2 * b - 1;
} else if (fabs(a - 1) <= 1e-4)
{
ans.push_back(1);
b *= 2;
}
} else if(b > 0.5)
{
ans.push_back(2);
b = 2 * b - 1;
}
}
reverse(ans.begin(), ans.end());
for (auto i : ans)
cout << i;
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
int _ = 1;
while (_--)
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3688kb
input:
0.5 0.25
output:
1
result:
ok ok
Test #2:
score: 0
Accepted
time: 0ms
memory: 3652kb
input:
1 0.75
output:
12
result:
ok ok
Test #3:
score: -100
Time Limit Exceeded
input:
1 0