QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#420826#6749. Targetyyk23610TL 0ms3800kbC++17605b2024-05-24 22:41:472024-05-24 22:41:48

Judging History

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

  • [2024-05-24 22:41:48]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:3800kb
  • [2024-05-24 22:41:47]
  • 提交

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: 0ms
memory: 3800kb

input:

0.5 0.25

output:

1

result:

ok ok

Test #2:

score: 0
Accepted
time: 0ms
memory: 3664kb

input:

1 0.75

output:

12

result:

ok ok

Test #3:

score: 0
Accepted
time: 0ms
memory: 3784kb

input:

1 0

output:

11111111111111

result:

ok ok

Test #4:

score: -100
Time Limit Exceeded

input:

0.361954 0.578805

output:

212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121...

result: