QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#420828#6749. Targetyyk23610TL 1ms3900kbC++14605b2024-05-24 22:43:372024-05-24 22:43:38

Judging History

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

  • [2024-05-24 22:43:38]
  • 评测
  • 测评结果:TL
  • 用时:1ms
  • 内存:3900kb
  • [2024-05-24 22:43:37]
  • 提交

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;
}

Details

Tip: Click on the bar to expand more detailed information

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...

result: