QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#570808 | #6749. Target | ranxi | TL | 0ms | 3876kb | C++14 | 794b | 2024-09-17 17:59:59 | 2024-09-17 18:00:00 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
#define alls(x) x.begin(),x.end()
#define ull unsigned long long
#define lowbit(x) x&-x
#define lc p<<1
#define rc p<<1|1
#define PII pair<int,int>
#define vi vector<int>
using namespace std;
const int mod = 998244353;
const int N = 2e5+10;
void solve()
{
long double a,b;
cin >> a >> b;
string ans;
while(fabs(a-b)>=1e-4)
{
if(a>b)
{
a = a*0.5;
ans+='1';
}
else
{
a = a*0.5+0.5;
ans+='2';
}
}
cout<<ans<<'\n';
}
signed main()
{
cout<<fixed<<setprecision(6);
ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
int _ = 1;
// cin >> _;
while(_--)solve();
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3712kb
input:
0.5 0.25
output:
1
result:
ok ok
Test #2:
score: 0
Accepted
time: 0ms
memory: 3876kb
input:
1 0.75
output:
12
result:
ok ok
Test #3:
score: 0
Accepted
time: 0ms
memory: 3784kb
input:
1 0
output:
11111111111111
result:
ok ok
Test #4:
score: -100
Time Limit Exceeded
input:
0.361954 0.578805