QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#372508 | #6749. Target | Qian# | TL | 1ms | 4088kb | C++14 | 720b | 2024-03-31 14:21:34 | 2024-03-31 14:21:34 |
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;
#define esp 1e-4
void solve()
{
dd a,b;
cin>>a>>b;
if(fabs(a-b)<=esp)return ;
vector<int>B,A;
while(fabs(b-int(b))>esp){
if(b<0.5)b=b*2,B.push_back(1);
else b=b*2-1,B.push_back(2);
}
while(fabs(a-b)>esp){
a/=2;A.push_back(1);
}
reverse(B.begin(),B.end());
if(A.size()+B.size()>50)while(1);
for(auto it:A)printf("%d",it);
for(auto it:B)printf("%d",it);
}
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: 4008kb
input:
0.5 0.25
output:
111111111111121
result:
ok ok
Test #2:
score: 0
Accepted
time: 0ms
memory: 3892kb
input:
1 0.75
output:
1111111111111122
result:
ok ok
Test #3:
score: 0
Accepted
time: 1ms
memory: 4088kb
input:
1 0
output:
11111111111111
result:
ok ok
Test #4:
score: -100
Time Limit Exceeded
input:
0.361954 0.578805