QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#372468#6749. TargetQian#WA 0ms3980kbC++141.4kb2024-03-31 13:55:022024-03-31 13:55:02

Judging History

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

  • [2024-03-31 13:55:02]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3980kb
  • [2024-03-31 13:55:02]
  • 提交

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, q;
	dd a, b;
	cin >> a >> b;
	// if (b == 0)
	// {
	// 	while (fabs(a - b) > 1e-4)
	// 	{
	// 		cout << 1;
	// 		a /= 2;
	// 	}
	// 	return;
	// }
	// if (b == 1)
	// {
	// 	while (fabs(a - b) > 1e-4)
	// 	{
	// 		cout << 2;
	// 		a = (a - 1) / 2 + 1;
	// 	}
	// 	return;
	// }
	while (fabs(a - b) > 1e-4)
	{
		if (b == 0)
		{
			q.push_back(1);
			a /= 2;
		} else if (b == 1)
		{
			q.push_back(2);
			a = (a - 1) / 2 + 1;
		}
		if (b < 0.5)
		{
			ans.push_back(1);
			b *= 2;
		} else if (b == 0.5)
		{
			if (fabs(a - 2 * b + 1) < fabs(a - 2 * b))
			{
				ans.push_back(2);
				b = 2 * b - 1;
			} else
			{
				ans.push_back(1);
				b *= 2;
			}
			// 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;
		}
	}
	for (auto i : q)
		cout << i;
	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: 0ms
memory: 3708kb

input:

0.5 0.25

output:

1

result:

ok ok

Test #2:

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

input:

1 0.75

output:

12

result:

ok ok

Test #3:

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

input:

1 0

output:

1111111111111111111111111111

result:

ok ok

Test #4:

score: -100
Wrong Answer
time: 0ms
memory: 3980kb

input:

0.361954 0.578805

output:

11111111111111111111111121221112221211112221111112111121121122121111212112

result:

wrong answer wa