本机有数,洛谷上全是零,求助鸽鸽们
查看原帖
本机有数,洛谷上全是零,求助鸽鸽们
73847
OYBDOOO楼主2020/11/17 23:37

可能是小数操作咕咯

/*=========================
Source:
Problem:
Author:OYBDOOO
Date:
Result:
=========================*/
#include<bits/stdc++.h>
using namespace std;
const int maxn=3e5+5;
int n;
double f[maxn],k;
char s[maxn];
int main()
{
	int i;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		cin>>s[i];
		if(s[i]=='x')
		{
			f[i]=f[i-1];
			k=0;
		}
		else if(s[i]=='o')
		{
			f[i]=f[i-1]+2*k+1;
			k+=1.0;
			break;
		}
		else if(s[i]=='?')
		{
			f[i]=f[i-1]+k+0.5;
			k=(k+1.0)/2.0;
		}
	}
	printf("%.4lf",f[n]);
	return 0;
}
2020/11/17 23:37
加载中...