QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#412368#6749. TargetXiaoretaW#TL 1ms3832kbC++14956b2024-05-16 12:38:512024-05-16 12:38:51

Judging History

你现在查看的是最新测评结果

  • [2024-05-16 12:38:51]
  • 评测
  • 测评结果:TL
  • 用时:1ms
  • 内存:3832kb
  • [2024-05-16 12:38:51]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define ll long long

const double eps = 1e-4;
int main() {
    double a, b; cin >> a >> b;
    string ans = "";
    if (b <= eps) {
        cout << string(40, '1') << '\n';
    } else {
        while (abs(b - a) > eps) {
            if (b - 0.5 > eps) {
                b = (b - 0.5) * 2.0;
                ans += '2';
            } else {
                if (abs(b - 0.5) <= eps) {
                    if (a <= eps) b = (b - 0.5) * 2.0, ans += '2';
                    else b = b * 2.0, ans += '1';
                } else {
                    b = b * 2.0;
                    ans += '1';
                }
            }
            // if (abs(b - 1) > eps)
            //     cout << fixed << setprecision(8) << a << ' ' << b << '\n';
            // else break;
        }
        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: 3492kb

input:

0.5 0.25

output:

1

result:

ok ok

Test #2:

score: 0
Accepted
time: 0ms
memory: 3572kb

input:

1 0.75

output:

12

result:

ok ok

Test #3:

score: 0
Accepted
time: 0ms
memory: 3832kb

input:

1 0

output:

1111111111111111111111111111111111111111

result:

ok ok

Test #4:

score: -100
Time Limit Exceeded

input:

0.361954 0.578805

output:


result: