码迷,mamicode.com
首页 > 其他好文 > 详细

NBUT Minecraft Server Bug

时间:2014-05-10 10:13:22      阅读:307      评论:0      收藏:0      [点我收藏+]

标签:des   blog   class   code   ext   c   

  • 问题描述
  • Oh Jesus! The Minecraft Server of XadillaX‘s came across a bug!
    There‘s one way to solve this bug in game. That is to get a bucket of water and a bucket of lava and mix them to obsidian. But remember, you must get water first, or the server will explode! Boom~

    bubuko.com,布布扣
    Fortunately there is a row of buckets at front of Hungar, he can save the world!

    bubuko.com,布布扣
    Some of buckets are filled with water and some are lava. Remember that Hungar can only move forward, that means when Hungar move to one bucket, he can‘t move back to the buckets behind this bucket. And he must get water first.
    Now give you the sort of buckets, please help Hungar to calculate out that how many ways he can save the world.

  • 输入
  • This problem contains several cases because of the XIONG HAI ZI, Minary.
    The first line of each case contains one integer N (0 < N ≤ 1000000) which indicates the number of buckets.
    Next line follows N buckets in from near to far which `W` indicates water and `L` indicates lava.
  • 输出
  • For each case, output the ways Hungar can save the Minecraft world.
  • 样例输入
  • 5W L W L L3W W L
  • 样例输出
  • 52

题意:求先拿W然后才能拿L的方法数

思路:记录L前有多少的W

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int MANX = 1000005;

int n;

int main(){
	while (scanf("%d%*c", &n) != EOF){
		int cnt = 0;
		long long ans = 0;
		int flag = 0;
		char ch;
		for (int i = 0; i < n; i++){
			scanf("%c", &ch);
			getchar();
			if (ch == ‘W‘ && !flag)
				flag = 1;
			if (ch == ‘W‘)
				cnt++;
			if (ch == ‘L‘ && flag)
				ans += cnt;
		}
		cout << ans << endl;
	}
	return 0;
}



NBUT Minecraft Server Bug,布布扣,bubuko.com

NBUT Minecraft Server Bug

标签:des   blog   class   code   ext   c   

原文地址:http://blog.csdn.net/u011345136/article/details/24991371

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!