QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#408520#6749. TargetH_ZzZ#WA 1ms3716kbC++201.7kb2024-05-10 16:16:142024-05-10 16:16:15

Judging History

This is the latest submission verdict.

  • [2024-05-10 16:16:15]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 3716kb
  • [2024-05-10 16:16:14]
  • Submitted

answer

#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<numeric>
#include<stack>
#include<string>
#include<vector>
#include<unordered_map>
#include<algorithm>
#include<cmath>
#include<cstring>
#include <bitset>
#include <map>
#include<queue>
#include <set>
#include<unordered_set>
#include<algorithm>
#include <functional>
#include <iomanip>
#include <time.h>
//#define int long long
#define endl '\n'
#define  X first
#define  V second
#define ce cout << endl;
#define lowbit(x) (x & -x)
using namespace std;
using LL = long long;
using pii = pair<int, int>;
using pdi = pair<double, int>;
using pip = pair<int, pii>;
using tiii = tuple<int, int, int>;
inline void ini();
const int mod = 1e9 + 7;
const int N = 2e5 + 5;

long double pw2[N];
void solve() {
	long double a, b;
	cin >> a >> b;
	if (a == b) {
		return;
	}
	for (int i = 1; i <= 50; i++) {
		long double c = b - a * pw2[i];
		if (c >= -1e-4 && c <= 1e-4) {
			for (int j = 0; j < i; j++) cout << 1;
			return;
		}
		else if (c < -1e-4) continue;
		string ans;
		for (int j = 1; j <= i; j++) {
			if (c-pw2[j] >= -1e-4 && c - pw2[j] <= 1e-4) {
				cout << ans << 2;
				for (int k = j + 2; k <= i; k++) cout << 1;
				return;
			}
			if (pw2[j] <= c) ans += '2', c -= pw2[j]; else ans += '1';
		}
		if (c > 1e-4) continue;
		reverse(ans.begin(), ans.end());
		cout << ans;
		return;
	}
}
void ini() {
	pw2[0] = 1;
	for (int i = 1; i <= 50; i++) pw2[i] = pw2[i - 1] * 0.5;
}
signed main() {

//	freopen("D:\\debug.txt", "r", stdin);

	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	ini();

	int T = 1;
	while (T--)
		solve();

	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

0.5 0.25

output:

1

result:

ok ok

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 3716kb

input:

1 0.75

output:

2

result:

wrong answer wa