原题下载
答案
#include <iostream>
#include <vector>
using namespace std;
int main() {
freopen("cow.in", "r", stdin);
freopen("cow.out", "w", stdout);
int N;
string S;
cin >> N >> S;
long long NC = 0;
long long NO = 0;
long long NW = 0;
for (int i = 0; i < N; i++) {
if (S[i] == 'C') {
NC++;
} else if (S[i] == 'O') {
NO += NC;
} else if (S[i] == 'W') {
NW += NO;
}
}
cout << NW << endl;
return 0;
}
以上就是关于【USACO 2015 February Contest, Bronze Problem 2. COW】的解答,如需了解学校/赛事/课程动态,可至翰林教育官网获取更多信息。
往期文章阅读推荐:
AMC/BPhO/UKChO…下半年20+赛事集中开考!抓住竞赛"黄金备赛期"!
2027 USAAIO人工智能奥赛报名进行中!Round 1新规出炉,2月开赛如何备考?

© 2026. All Rights Reserved. 沪ICP备2023009024号-1