QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#414196 | #6749. Target | heavenMOJANG | WA | 106ms | 3900kb | C++23 | 765b | 2024-05-18 17:07:12 | 2024-05-18 17:07:13 |
Judging History
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-6;
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;
}
詳細信息
Test #1:
score: 100
Accepted
time: 18ms
memory: 3716kb
input:
0.5 0.25
output:
2222222222222222211
result:
ok ok
Test #2:
score: 0
Accepted
time: 106ms
memory: 3880kb
input:
1 0.75
output:
12222222222222222212
result:
ok ok
Test #3:
score: 0
Accepted
time: 0ms
memory: 3900kb
input:
1 0
output:
11111111111111111111
result:
ok ok
Test #4:
score: 0
Accepted
time: 40ms
memory: 3792kb
input:
0.361954 0.578805
output:
1121122121111212112
result:
ok ok
Test #5:
score: -100
Wrong Answer
time: 34ms
memory: 3752kb
input:
0.144888 0.140086
output:
result:
wrong answer wa