原題下載
答案
#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;
}
以上就是關(guān)于【USACO 2015 February Contest, Bronze Problem 2. COW】的解答,如需了解學(xué)校/賽事/課程動(dòng)態(tài),可至翰林教育官網(wǎng)獲取更多信息。
往期文章閱讀推薦:
【組隊(duì)招募】經(jīng)濟(jì)/數(shù)模競賽CNEC/IEO/SIC/HiMCM…組隊(duì)報(bào)名!
NOAI人工智能奧賽 2026-2027 活動(dòng)章程出爐:新規(guī)則必看!

? 2026. All Rights Reserved. 滬ICP備2023009024號-1