QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#751621#9746. 平方根xdz_#AC ✓3ms5360kbC++20777b2024-11-15 19:49:402024-11-15 19:49:41

Judging History

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

  • [2024-11-15 19:49:41]
  • 评测
  • 测评结果:AC
  • 用时:3ms
  • 内存:5360kb
  • [2024-11-15 19:49:40]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define fi first
#define se second
#define endl '\n'

typedef pair<int,int> PII;

void solve(){
	string s;
	cin >>s;
	int n =s.size();
	s = " " + s;
	int now = 0;
	double ans = 0;
	for(int i = 1;i <= n;i ++){
		if(s[i] == '1'){
			now ++;
		}
		else{
			if(now % 2 != 0){
				ans += ((now + 1) * 1.0) / 2.0;
			}
			else if(now){
				ans += ((now - 2) * 1.0 / 2.0) + sqrt(2);
			}
			now = 0;
		}
	}
	if(now % 2 != 0){
		ans += ((now + 1) * 1.0) / 2.0;
	}
	else if(now){
		ans += ((now - 2) * 1.0 / 2.0) + sqrt(2);
	}
	printf("%.10lf",ans);
}

signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int T;
	T = 1;
	while(T --){
		solve();
	}
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

1100110111

output:

4.8284271247

result:

ok found '4.828427125', expected '4.828427125', error '0.000000000'

Test #2:

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

input:

0

output:

0.0000000000

result:

ok found '0.000000000', expected '0.000000000', error '-0.000000000'

Test #3:

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

input:

1

output:

1.0000000000

result:

ok found '1.000000000', expected '1.000000000', error '0.000000000'

Test #4:

score: 0
Accepted
time: 3ms
memory: 5360kb

input:

000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

0.0000000000

result:

ok found '0.000000000', expected '0.000000000', error '-0.000000000'

Test #5:

score: 0
Accepted
time: 3ms
memory: 5252kb

input:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

output:

500000.4142135624

result:

ok found '500000.414213562', expected '500000.414213562', error '0.000000000'

Test #6:

score: 0
Accepted
time: 3ms
memory: 5228kb

input:

010101111011001000011101100000011110101010000110011110101010111011010011100001100000001011100111110000100101100011101101000100110100111101001100011000101000000101011101000011011001111011101101100010110110001111011001010100110011111101000010010011011101100001101001101010011011100110101001101111010101...

output:

367851.9867876115

result:

ok found '367851.986787612', expected '367851.986787086', error '0.000000000'

Test #7:

score: 0
Accepted
time: 3ms
memory: 5228kb

input:

000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

299931.3137084990

result:

ok found '299931.313708499', expected '299931.313708499', error '0.000000000'

Extra Test:

score: 0
Extra Test Passed