其他分享
首页 > 其他分享> > Wannafly Camp 2020 Day 2A 托米的字符串

Wannafly Camp 2020 Day 2A 托米的字符串

作者:互联网

#include <bits/stdc++.h>
using namespace std;
const int N = 1000005;
int n;
char str[N];
int a[N];

int main() {
    scanf("%s",str+1);
    n=strlen(str+1);
    for(int i=1;i<=n;i++) {
        if(str[i]=='a' || str[i]=='e' || str[i]=='i'
           || str[i]=='o' || str[i]=='u' || str[i]=='y')
            a[i]=a[i-1]+1;
        else a[i]=a[i-1];
    }
    double ans = 0;
    double tmp = 0;
    for(int i=1;i<=n;i++) {
        if(i==1) tmp=a[n];
        else tmp+=a[n-i+1]-a[i-1];
        ans += tmp/i;
    }
    printf("%.8lf",ans/n/(n+1)*2);
}

标签:std,char,1000005,int,Camp,Wannafly,str,托米
来源: https://www.cnblogs.com/mollnn/p/12261629.html