QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#407530#6749. Targetmxxnez#WA 1ms3876kbC++17829b2024-05-08 22:12:362024-05-08 22:12:38

Judging History

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

  • [2024-05-08 22:12:38]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3876kb
  • [2024-05-08 22:12:36]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
const double esp = 1e-4;
#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: 3876kb

input:

0.5 0.25

output:

111111111111121

result:

ok ok

Test #2:

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

input:

1 0.75

output:

1111111111111122

result:

ok ok

Test #3:

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

input:

1 0

output:

11111111111111

result:

ok ok

Test #4:

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

input:

0.361954 0.578805

output:

1111111111112111111112111111121112112

result:

wrong answer wa