QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#760862#9746. 平方根chensunyishuoWA 0ms3756kbC++11504b2024-11-18 19:51:202024-11-18 19:51:23

Judging History

This is the latest submission verdict.

  • [2024-11-18 19:51:23]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3756kb
  • [2024-11-18 19:51:20]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
	ios::sync_with_stdio(false);
	char x;
	string s;
	cin >> s;
	s += '0';
	int cnt = 0;
	double ans = 0;
	for (size_t i = 0; i < s.size(); i++) {
		if (s[i] == '1') {
			cnt++;
		} else {
			if (cnt == 0) {
				continue;
			}
			if (cnt % 2 == 0) {
				ans += (cnt / 2 - 1);
				ans += sqrt(2);
			} else {
				ans += (cnt / 2 + 1);
			}
			cnt = 0;
		}
	}
	cout << ans << endl;
	return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3756kb

input:

1100110111

output:

4.82843

result:

wrong answer 1st numbers differ - expected: '4.8284271', found: '4.8284300', error = '0.0000006'