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

好烦,水题花了那么长时间还做不出来,然后。。。。就没有然后了。。。。

时间:2014-08-20 17:48:32      阅读:216      评论:0      收藏:0      [点我收藏+]

标签:os   io   for   ar   div   amp   时间   line   

h 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~
Fortunately there is a row of buckets at front of Hungar, he can save the world!


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.

Input

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. 

Output

For each case, output the ways Hungar can save the Minecraft world.

Sample Input

5
W L W L L
3
W W L

Sample Output

5
2

#include<stdio.h>
main()
{
int n,i,m,sum,t,p;
char x[1000100];
char y[1000100];
while(scanf("%d",&n)!=EOF)
{sum=0;t=0;p=0;
for(i=1;i<=n;i++)
scanf("%s",&x[i]);
for(i=1;i<=n;i++)
{
y[i]=x[n-i+1];
}
for(i=1;i<=n;i++)
{
if(y[i]==‘W‘)
{
sum=sum+i-1;
p=p+t;
t=t+1;
}
}
printf("%d\n",sum=sum-p);
}return 0;
}

不知道自己哪里错了,排序暴力直接超时,找到规律居然WA,先放着吧。。。。。

好烦,水题花了那么长时间还做不出来,然后。。。。就没有然后了。。。。,布布扣,bubuko.com

好烦,水题花了那么长时间还做不出来,然后。。。。就没有然后了。。。。

标签:os   io   for   ar   div   amp   时间   line   

原文地址:http://www.cnblogs.com/alexanderone/p/3925058.html

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