QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#420828 | #6749. Target | yyk23610 | TL | 1ms | 3900kb | C++14 | 605b | 2024-05-24 22:43:37 | 2024-05-24 22:43:38 |
Judging History
answer
#include<iostream>
using namespace std;
double js1(double a){
a = 0.5*a;
return a;
}
double js2(double a){
a = 0.5*a+0.5;
return a;
}
int main(){
double a,b;
cin>>a>>b;
// cout<<a<<" "<<b<<endl;
// string str = "";
while(abs(a-b)>0.0001){
double k1 = js1(a);
double k2 = js2(a);
// cout<<k1<<" "<<k2<<endl;
if(a == k1){
a = k2;
cout<<2;
}
else if(a == k2){
a = k1;
cout<<1;
}
else if(abs(k1-b)>abs(k2-b)){
a = k2;
cout<<2;
}
else{
a = k1;
cout<<1;
}
}
// cout<<"a";
// cout<<str;
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3768kb
input:
0.5 0.25
output:
1
result:
ok ok
Test #2:
score: 0
Accepted
time: 0ms
memory: 3724kb
input:
1 0.75
output:
12
result:
ok ok
Test #3:
score: 0
Accepted
time: 0ms
memory: 3900kb
input:
1 0
output:
11111111111111
result:
ok ok
Test #4:
score: -100
Time Limit Exceeded
input:
0.361954 0.578805
output:
212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...