QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#763348 | #9746. 平方根 | UESTC_NLNS# | AC ✓ | 17ms | 6372kb | C++17 | 578b | 2024-11-19 19:42:51 | 2024-11-19 19:42:52 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using ldb = long double;
int main(){
string s;
cin>>s;
int n = s.size();
vector<int> a;
for(int i = 0;i<n;){
int j = i;
while(j<n && s[j]=='0')j++;
if(j==n)break;
int k = j;
while(k<n && s[k]=='1')k++;
a.push_back(k-j);
i = k;
}
ldb ans = 0;
for(const auto u:a){
// cout<<u<<'\n';
ans += (u+1)/2 + (sqrtl(2) - 1)*((u+1)%2);
// cout<<ans<<'\n';
}
printf("%.9LF",ans);
}
/*
1100110111
*/
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3860kb
input:
1100110111
output:
4.828427125
result:
ok found '4.828427125', expected '4.828427125', error '0.000000000'
Test #2:
score: 0
Accepted
time: 0ms
memory: 4028kb
input:
0
output:
0.000000000
result:
ok found '0.000000000', expected '0.000000000', error '-0.000000000'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3740kb
input:
1
output:
1.000000000
result:
ok found '1.000000000', expected '1.000000000', error '0.000000000'
Test #4:
score: 0
Accepted
time: 12ms
memory: 5408kb
input:
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
output:
0.000000000
result:
ok found '0.000000000', expected '0.000000000', error '-0.000000000'
Test #5:
score: 0
Accepted
time: 12ms
memory: 5276kb
input:
111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...
output:
500000.414213562
result:
ok found '500000.414213562', expected '500000.414213562', error '0.000000000'
Test #6:
score: 0
Accepted
time: 17ms
memory: 6372kb
input:
010101111011001000011101100000011110101010000110011110101010111011010011100001100000001011100111110000100101100011101101000100110100111101001100011000101000000101011101000011011001111011101101100010110110001111011001010100110011111101000010010011011101100001101001101010011011100110101001101111010101...
output:
367851.986787086
result:
ok found '367851.986787086', expected '367851.986787086', error '0.000000000'
Test #7:
score: 0
Accepted
time: 13ms
memory: 5360kb
input:
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
output:
299931.313708499
result:
ok found '299931.313708499', expected '299931.313708499', error '0.000000000'
Extra Test:
score: 0
Extra Test Passed