QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#372454#6749. TargetQian#TL 1ms3688kbC++14847b2024-03-31 13:42:352024-03-31 13:42:36

Judging History

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

  • [2024-03-31 13:42:36]
  • 评测
  • 测评结果:TL
  • 用时:1ms
  • 内存:3688kb
  • [2024-03-31 13:42:35]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define dd double
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define pii pair<int, int>

const int N = 1e6 + 10;
int n, a[N],b[N];
int sum[N];
void solve()
{
	vector<ll> ans;
	dd a, b;
	cin >> a >> b;
	while (fabs(a - b) > 1e-4)
	{
		if (b < 0.5)
		{
			ans.push_back(1);
			b *= 2;
		} else if (b == 0.5)
		{
			if (fabs(a) <= 1e-4)
			{
				ans.push_back(2);
				b = 2 * b - 1;
			} else if (fabs(a - 1) <= 1e-4)
			{
				ans.push_back(1);
				b *= 2;
			}
		} else if(b > 0.5)
		{
			ans.push_back(2);
			b = 2 * b - 1;
		}
	}
	reverse(ans.begin(), ans.end());
	for (auto i : ans)
		cout << i;
}

signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int _ = 1;
	while (_--)
		solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3688kb

input:

0.5 0.25

output:

1

result:

ok ok

Test #2:

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

input:

1 0.75

output:

12

result:

ok ok

Test #3:

score: -100
Time Limit Exceeded

input:

1 0

output:


result: