QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#414331#6749. Targetfuyouyufeng#WA 1ms3848kbC++171.7kb2024-05-18 21:25:512024-05-18 21:25:51

Judging History

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

  • [2024-05-18 21:25:51]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3848kb
  • [2024-05-18 21:25:51]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
const int p = 998244353;
double s = 0.5;
bool check(double a, double b)
{
    return abs(a - b) <= 1e-4;
}
vector<int> res;
vector<int> ans;

int main()
{
    double a, b;
    cin >> a >> b;
    for (int k = 0; k <= 50; k++)
    {
        bool ok = false;
        for (int l = 0; l <= k; l++)
        {
            double t = a;
            for (int i = 1; i <= l; i++)
                t *= 0.5;
            for (int i = 1; i <= k - l; i++)
                t = t * 0.5 + 0.5;
            if (check(t, b))
            {

                for (int i = 1; i <= l; i++)
                    res.push_back(1);
                for (int i = 1; i <= k - l; i++)
                    res.push_back(2);
                ok = true;
                break;
            }
        }
        if (ok)
            break;
    }

    for (int k = 0; k <= 50; k++)
    {
        bool ok = false;
        for (int l = 0; l <= k; l++)
        {
            double t = a;
            for (int i = 1; i <= l; i++)
                t = t * 0.5 + 0.5;

            for (int i = 1; i <= k - l; i++)
                t *= 0.5;
            if (check(t, b))
            {

                for (int i = 1; i <= l; i++)
                    ans.push_back(2);
                for (int i = 1; i <= k - l; i++)
                    ans.push_back(1);
                ok = true;
                break;
            }
        }
        if (ok)
            break;
    }
    if (ans.size())
    {
        for (int i = 0; i < ans.size(); i++)
            cout << ans[i];
        return 0;
    }

    for (int i = 0; i < res.size(); i++)
        cout << res[i];
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

0.5 0.25

output:

1

result:

ok ok

Test #2:

score: 0
Accepted
time: 1ms
memory: 3660kb

input:

1 0.75

output:

12

result:

ok ok

Test #3:

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

input:

1 0

output:

11111111111111

result:

ok ok

Test #4:

score: -100
Wrong Answer
time: 1ms
memory: 3724kb

input:

0.361954 0.578805

output:


result:

wrong answer wa