#25531: c++解答


yp10952161@yphs.tp.edu.tw (無)

學校 : 臺北市私立延平高級中學
編號 : 146286
來源 : [203.72.178.2]
最後登入時間 :
2023-07-11 11:49:59

#include <bits/stdc++.h>

using namespace std;

int main()

    ios::sync_with_stdio(false); 

    string s; 

    while(cin>>s)

    {   

        int p=0,ans=0; 

        for(int i=0; i<s.length(); i++) 

            if(s[i]=='y') {ans+=abs(i-p); p+=3;} 

        cout<<ans<<'\n';

    }

}