QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#784771#9746. 平方根ChuanhuaYu#AC ✓4ms6176kbC++17785b2024-11-26 15:54:532024-11-26 15:55:06

Judging History

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

  • [2024-11-26 15:55:06]
  • 评测
  • 测评结果:AC
  • 用时:4ms
  • 内存:6176kb
  • [2024-11-26 15:54:53]
  • 提交

answer

// Author: Chuanhua Yu
// Time: 2024-11-26.
#include<bits/stdc++.h>
using namespace std;
using ll = long long;

string s;
double sq2 = sqrt(double(2));

void solve(){
    cin >> s;
    s = s + '0';
    vector<int> cnt;
    int cc = 0;
    for(auto c : s) {
        if(c == '0'){
            if(cc) cnt.push_back(cc);
            cc = 0;
        }
        else cc++;
    }
    double ans = 0;
    for(auto c : cnt){
        if(c & 1) ans += c / 2 + 1;
        else if (c == 2) ans += sq2;
        else ans += sq2 + (c - 2) / 2;
    }
    cout << fixed << setprecision(12) << ans << '\n';
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
//    int T; cin >> T;
//    while(T--)
    solve();
    return 0;
}

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

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3872kb

input:

1100110111

output:

4.828427124746

result:

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

Test #2:

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

input:

0

output:

0.000000000000

result:

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

Test #3:

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

input:

1

output:

1.000000000000

result:

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

Test #4:

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

input:

000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

0.000000000000

result:

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

Test #5:

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

input:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

output:

500000.414213562384

result:

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

Test #6:

score: 0
Accepted
time: 4ms
memory: 6176kb

input:

010101111011001000011101100000011110101010000110011110101010111011010011100001100000001011100111110000100101100011101101000100110100111101001100011000101000000101011101000011011001111011101101100010110110001111011001010100110011111101000010010011011101100001101001101010011011100110101001101111010101...

output:

367851.986787611502

result:

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

Test #7:

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

input:

000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

299931.313708499016

result:

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

Extra Test:

score: 0
Extra Test Passed