QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#407545#6749. Targetmxxnez#WA 1ms3880kbC++17829b2024-05-08 23:09:422024-05-08 23:09:44

Judging History

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

  • [2024-05-08 23:09:44]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3880kb
  • [2024-05-08 23:09:42]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
const double esp = 1e-9;
#define i64 long long 
void solve(){
    double a,b;// int cnt = 0;
    cin >> a >> b;
   // cout << a << b;
    if (abs(a - b) <= esp){
        cout << endl;
        return;
    }
    
    double tmp = b;
    vector<int> t;
    int x = 2, cnt = 1;
    
    while (tmp > esp){
    	
    	while (tmp < 1.0 / x)
    	{
    		x *= 2;
    		cnt++;
		}
    	tmp -= (1.0 / x);
    	t.push_back(cnt);
    	x *= 2; cnt++;
	}

	tmp = a;
	while (abs(tmp) > esp){
		tmp /= 2;
		cout << 1;
	}

	for (int i = t.size() - 1; i >= 0; i--){
		cout << 2;
		for (int j = i; j < t[i] - 1; j++)
			cout << 1;
	}
    cout << endl;
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
	solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

0.5 0.25

output:

1111111111111111111111111111121

result:

ok ok

Test #2:

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

input:

1 0.75

output:

11111111111111111111111111111122

result:

ok ok

Test #3:

score: 0
Accepted
time: 1ms
memory: 3724kb

input:

1 0

output:

111111111111111111111111111111

result:

ok ok

Test #4:

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

input:

0.361954 0.578805

output:

11111111111111111111111111111211111111111111112111111111111211111111112111111112111111112111111121112112

result:

wrong answer wa