QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#414198#6749. TargetheavenMOJANGTL 0ms0kbC++23765b2024-05-18 17:08:242024-05-18 17:08:25

Judging History

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

  • [2024-05-18 17:08:25]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2024-05-18 17:08:24]
  • 提交

answer

#pragma GCC optimize(1)
#pragma GCC optimize(2)
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
constexpr int inf=0x7fffffff;
constexpr double eps=1e-8;
signed main(){
    std::cin.tie(0)->sync_with_stdio(0);
    double a,b;cin>>a>>b;
    string s="";
    double aa=a;
    while(a-0.0>=eps) a/=2.0,s+="1";
    int n=s.size();
    for(int i=0;i<(1ll<<n);++i){
        string t=s;
        for(int j=0;j<n;++j){
            if((1ll<<j)&i) t[j]='2';
        }
        double tmp=aa;
        for(int j=0;j<n;++j) 
            if(t[j]=='1') tmp/=2.0;
            else tmp=tmp/2.0+0.5;
        if(abs(tmp-b)<=eps){cout<<t<<"\n";break;}
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Time Limit Exceeded

input:

0.5 0.25

output:


result: