QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#383518 | #6749. Target | qzhfx# | TL | 1ms | 3932kb | C++23 | 1.0kb | 2024-04-09 15:12:23 | 2024-04-09 15:12:25 |
Judging History
answer
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math,no-stack-protector")
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
using namespace std;
using ll = int64_t;
using LL = long long;
using ull = uint64_t;
using i128 = __int128_t;
using u128 = __uint128_t;
using pii = pair<ll, ll>;
const int mod = 998244353;
const int N = 1e6 + 7;
const int maxn = 1e5 + 100;
const double eps = 1e-4;
void solve() {
double a, b;
const double s = 0.5;
cin >> a >> b;
vector<int>ans;
while(1){
if(fabs(1.0-b)<eps){
break;
}
if(b*2.0>1){
b = 2.0 * b - 1.0;
ans.push_back(2);
}else {
b = b * 2.0;
ans.push_back(1);
}
// cerr << b << '\n';
}
while(fabs(1.0-a)>eps){
ans.push_back(2);
a = a * 0.5 + 0.5;
}
reverse(ans.begin(),ans.end());
for(auto x:ans){
cout << x;
}
cout << '\n';
}
int main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int _;
_ = 1;
// cin >> _;
while (_--) {
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3932kb
input:
0.5 0.25
output:
222222222222211
result:
ok ok
Test #2:
score: 0
Accepted
time: 0ms
memory: 3820kb
input:
1 0.75
output:
12
result:
ok ok
Test #3:
score: -100
Time Limit Exceeded
input:
1 0