QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#383528#6749. Targetqzhfx#WA 0ms3952kbC++231.1kb2024-04-09 15:17:362024-04-09 15:17:36

Judging History

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

  • [2024-04-09 15:17:36]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3952kb
  • [2024-04-09 15:17:36]
  • 提交

answer

#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math,no-stack-protector")
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
using namespace std;
using ll = int64_t;
using LL = long long;
using ull = uint64_t;
using i128 = __int128_t;
using u128 = __uint128_t;
using pii = pair<ll, ll>;
const int mod = 998244353;
const int N = 1e6 + 7;
const int maxn = 1e5 + 100;
const double eps = 1e-4;

void solve() {
	double a, b;
	const double s = 0.5;
	cin >> a >> b;

	vector<int>ans,v;
	while(fabs(a)>eps){
		a = a * 0.5;
		v.push_back(1);
	}
	while(1){
		if(fabs(1.0-b)<eps||ans.size() > 40){
			break;
		}
		if(b*2.0>1){
			b = 2.0 * b - 1.0;
			ans.push_back(2);
		}else {
			b = b * 2.0;
			ans.push_back(1);
		}
		// cerr << b << '\n';

	}
	while(fabs(1.0-a)>eps){
		ans.push_back(2);
		a = a * 0.5 + 0.5;
	}
	reverse(ans.begin(),ans.end());
	for(auto x:v){
		cout << x ;
	}
	for(auto x:ans){
		cout << x;
	}
	cout << '\n';
}
int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int _;
	_ = 1;
	// cin >> _;
	while (_--) {
		solve();
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

0.5 0.25

output:

11111111111112222222222222211

result:

ok ok

Test #2:

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

input:

1 0.75

output:

111111111111112222222222222212

result:

ok ok

Test #3:

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

input:

1 0

output:

111111111111112222222222222211111111111111111111111111111111111111111

result:

wrong answer wa