QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#383518#6749. Targetqzhfx#TL 1ms3932kbC++231.0kb2024-04-09 15:12:232024-04-09 15:12:25

Judging History

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

  • [2024-04-09 15:12:25]
  • 评测
  • 测评结果:TL
  • 用时:1ms
  • 内存:3932kb
  • [2024-04-09 15:12:23]
  • 提交

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;
	
	while(1){
		if(fabs(1.0-b)<eps){
			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: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: 1ms
memory: 3932kb

input:

0.5 0.25

output:

222222222222211

result:

ok ok

Test #2:

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

input:

1 0.75

output:

12

result:

ok ok

Test #3:

score: -100
Time Limit Exceeded

input:

1 0

output:


result: