QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#402046#6749. Targetiwew#TL 0ms3784kbC++20495b2024-04-29 19:58:062024-04-29 19:58:06

Judging History

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

  • [2024-04-29 19:58:06]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:3784kb
  • [2024-04-29 19:58:06]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

const double eps = 1e-4;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	double a, b;
	cin >> a >> b;

	const double s = 0.5;
	auto up = [&](double &v) -> void {
		v = (v - 1) * s + 1;
	};

	auto down = [&](double &v) -> void {
		v = v * s;
	};

	string ans;
	while(fabs(a - b) > eps) {
		if(a < b) {
			up(a);
			ans += '2';
		} else {
			down(a);
			ans += '1';
		}
	}
	cout << ans << '\n';
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3620kb

input:

0.5 0.25

output:

1

result:

ok ok

Test #2:

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

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:


result: