QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#412356#6749. TargetXiaoretaW#WA 1ms3600kbC++14849b2024-05-16 12:21:242024-05-16 12:21:25

Judging History

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

  • [2024-05-16 12:21:25]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3600kb
  • [2024-05-16 12:21:24]
  • 提交

answer

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

const double eps = 1e-3;
int main() {
    long double a, b; cin >> a >> b;
    string ans = "";
    if (b <= eps) {
        while (a > eps) {
            ans += '1';
            a /= 2.0;
        }
    } else {
        while (abs(b - a) > eps) {
            if (b - 0.5 >= eps) {
                b = (b - 0.5) * 2.0;
                // b = (b - 1) / 0.5 + 1;
                ans += '2';
            } else {
                b = b * 2.0;
                ans += '1';
            }
            // cout << fixed << setprecision(8) << a << ' ' << b << '\n';
            if (abs(b - 1) <= eps) break;
        }
        reverse(ans.begin(), ans.end());
    }
    
    // cout << "LEn: " << ans.size() << '\n';
    cout << ans << '\n';
    
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3600kb

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: -100
Wrong Answer
time: 0ms
memory: 3500kb

input:

1 0

output:

1111111111

result:

wrong answer wa