QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#407541#6749. Targetmxxnez#WA 0ms3724kbC++17866b2024-05-08 22:57:082024-05-08 22:57:08

Judging History

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

  • [2024-05-08 22:57:08]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3724kb
  • [2024-05-08 22:57:08]
  • 提交

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 (abs(tmp) > esp){
    	
    	while (tmp < 1.0 / x)
    	{
    		x *= 2;
    		cnt++;
		}
    	tmp -= (1.0 / x);
    	tmp = abs(tmp);
    	t.push_back(cnt);
    	x *= 2; cnt++;
	}

	tmp = a;
	for(int i = 0 ; i < 20 ; i++){
		cout << 1;
	}
	string s=" ";
	for (int i = t.size() - 1; i >= 0; i--){
		s = "2"+s;
		for (int j = i; j < t[i] - 1; j++)
			s= "1"+s;
	}
    cout <<s<< 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: 0
Wrong Answer
time: 0ms
memory: 3724kb

input:

0.5 0.25

output:

1111111111111111111112 

result:

wrong answer wa