QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#570808#6749. TargetranxiTL 0ms3876kbC++14794b2024-09-17 17:59:592024-09-17 18:00:00

Judging History

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

  • [2024-09-17 18:00:00]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:3876kb
  • [2024-09-17 17:59:59]
  • 提交

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

output:


result: