# Bzoj3450 tyvj1952 easy

Posted by yjjr's blog on February 6, 2018

Description

Sevenkplus闲的慌就看他打了一盘，有些地方跟运气无关要么是o要么是x，有些地方o或者x各有50%的可能性，用?号来表示。

Input

Output

Sample Input

4
????

Sample Output

4.1250

n<=300000
osu很好玩的哦
WJMZBMR技术还行(雾),x基本上很少呢

F[i]表示前i项的期望值，g[i]表示当前一段区间内连续一段‘o’的期望长度

Code

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define dep(i,a,b) for(int i=a;i>=b;i--)
#define ll long long
#define mem(x,num) memset(x,num,sizeof x)
#ifdef WIN32
#define LL "%I64d"
#else
#define LL "%lld"
#endif
using namespace std;
{
ll f=1,x=0;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
}
const int maxn=3e5+6;
int n;
double g[maxn],f[maxn];
char ch;
int main()
{
rep(i,1,n){
ch=getchar();
if(ch=='o'){g[i]=g[i-1]+1;f[i]=f[i-1]+2*g[i-1]+1;}
if(ch=='x'){g[i]=0;f[i]=f[i-1];}
if(ch=='?'){g[i]=g[i-1]/2+0.5;f[i]=f[i-1]+g[i-1]+0.5;}
}
printf("%.4lf\n",f[n]);
return 0;
}