0
点赞
收藏
分享

微信扫一扫

COW(dp、递推)

前程有光 2022-02-26 阅读 51

题目描述:

在这里插入图片描述

主要思路:

#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll;
int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    ll c=0,o=0,w=0;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='C') c+=1;
        else if(s[i]=='O') o+=c;
        else w+=o;
    }
    cout<<w<<endl;
    return 0;
}
举报

相关推荐

0 条评论