QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#383436#6749. Targetyouxiao#TL 1ms3848kbC++20732b2024-04-09 14:11:112024-04-09 14:11:11

Judging History

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

  • [2024-04-09 14:11:11]
  • 评测
  • 测评结果:TL
  • 用时:1ms
  • 内存:3848kb
  • [2024-04-09 14:11:11]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=11000;
const double eps=1e-5;

int check(double x){
    if(abs(x)<eps)return 0;
    if(x>0)return 1;
    return -1;
}

int main(){
    #ifdef LOCAL
    freopen("input.in","r",stdin);
    freopen("output.out","w",stdout);
    #endif
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    double a,b;
    cin>>a>>b;
    while(1){
        int f=check(a-b);
        // cerr<<a<<" "<<b<<endl;
        if(f==0){
            break;
        }
        if(f==1){
            a/=2.0;
            cout<<1;
        }
        if(f==-1){
            a=(a+1.0)/2;
            cout<<2;
        }
    }
    cout<<endl;
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3780kb

input:

0.5 0.25

output:

1

result:

ok ok

Test #2:

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

input:

1 0.75

output:

12

result:

ok ok

Test #3:

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

input:

1 0

output:

11111111111111111

result:

ok ok

Test #4:

score: -100
Time Limit Exceeded

input:

0.361954 0.578805

output:

212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result: