[noj 1552] Minecraft Server Bug

来源:互联网 发布:八百米跑 知乎 编辑:程序博客网 时间:2024/04/26 18:02

题意是:有一排的水或者熔岩,你需要先拿水再拿熔岩,问有多少种拿的方式。

依次统计每次的W,然后每次碰到L就加一次W的数量即可。

#include<iostream>using namespace std;int main(){int n;char c;while(~scanf("%d\n", &n)){__int64 cnt = 0, re = 0;for(int i = 0; i < n; i++){c = getchar();if(c == 'W')cnt++;else if(c == 'L')re += cnt;getchar();}printf("%I64d\n",re);}return 0;}


0 0