QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#410339 | #6749. Target | yi_y# | TL | 0ms | 0kb | C++11 | 496b | 2024-05-13 21:48:27 | 2024-05-13 21:48:27 |
answer
#include <bits/stdc++.h>
using namespace std;
double a , b;
int f(double a , double b,int i){
double t,tt;
t=(a-b);
tt=t*pow(2,i);
if(tt==1) return 1;
else return 0;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> a >> b;
int i = 1;
while(fabs(a-b)>0.00001){
if(a*0.5>=b||f(a,b,i)==1){
cout << 1;
a=a*0.5;
}
if(a*0.5<b){
cout << 2;
a=a*0.5+0.5;
}
/*cout << endl;
cout << a << endl;*/
i++;
}
return 0;
}
详细
Test #1:
score: 0
Time Limit Exceeded
input:
0.5 0.25
output:
121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212...