COW
COW
时间限制: 1 Sec 内存限制: 64 MB
提交: 41 解决: 18
[提交][状态][讨论版]
题目描述
the cow has stumbled across an intriguing inscription carved into a
large stone in the middle of her favorite grazing field. The text of the
inscription appears to be from a cryptic ancient language involving an
alphabet with only the three characters C, O, and W. Although Bessie
cannot decipher the text, she does appreciate the fact that C, O, and W
in sequence forms her favorite word, and she wonders how many times COW
appears in the text.
Bessie doesn't mind if there are other
characters interspersed within COW, only that the characters appear in
the correct order. She also doesn't mind if different occurrences of COW
share some letters. For instance, COW appears once in CWOW, twice in
CCOW, and eight times in CCOOWW.
Given the text of the inscription, please help Bessie count how many times COW appears.
输入
first line of input consists of a single integer N <= 10^5. The
second line contains of a string of N characters, where each character
is either a C, O, or W.
输出
Note that the answer can be very large, so
make sure to use 64 bit integers ("long long" in C++, "long" in Java)
to do your calculations.
样例输入
6
COOWWW
样例输出
6
【分析】模拟一下就行了
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#include<functional>
#define mod 1000000007
#define inf 0x3f3f3f3f
#define pi acos(-1.0)
using namespace std;
typedef long long ll;
const int N=;
const int M=;
char s[N];
int n,m;
ll sc=,sco=,scow=;
int main(){
scanf("%d%s",&n,s);
for(int i=;i<n;i++){
if(s[i]=='C')sc++;
if(s[i]=='O')sco+=sc;
if(s[i]=='W')scow+=sco;
}
printf("%lld\n",scow);
return ;
}
COW的更多相关文章
- POJ 3278 Catch That Cow(bfs)
传送门 Catch That Cow Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 80273 Accepted: 25 ...
- 【BZOJ1623】 [Usaco2008 Open]Cow Cars 奶牛飞车 贪心
SB贪心,一开始还想着用二分,看了眼黄学长的blog,发现自己SB了... 最小道路=已选取的奶牛/道路总数. #include <iostream> #include <cstdi ...
- HDU Cow Sorting (树状数组)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2838 Cow Sorting Problem Description Sherlock's N (1 ...
- [BZOJ1604][Usaco2008 Open]Cow Neighborhoods 奶牛的邻居
[BZOJ1604][Usaco2008 Open]Cow Neighborhoods 奶牛的邻居 试题描述 了解奶牛们的人都知道,奶牛喜欢成群结队.观察约翰的N(1≤N≤100000)只奶牛,你会发 ...
- 细读cow.osg
细读cow.osg 转自:http://www.cnblogs.com/mumuliang/archive/2010/06/03/1873543.html 对,就是那只著名的奶牛. //Group节点 ...
- POJ 3176 Cow Bowling
Cow Bowling Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 13016 Accepted: 8598 Desc ...
- raw,cow,qcow,qcow2镜像的比较
在linux下,虚拟机的选择方式有很多,比如vmware for linux,virtual box,还有qemu,在以前,使用qemu的人不多,主要是使用起来有些麻烦,但现在随着Openstack的 ...
- poj1985 Cow Marathon (求树的直径)
Cow Marathon Time Limit: 2000MS Memory Limit: 30000K Total Submissions: 3195 Accepted: 1596 Case ...
- (01背包变形) Cow Exhibition (poj 2184)
http://poj.org/problem?id=2184 Description "Fat and docile, big and dumb, they look so stupid ...
- 图论 ---- spfa + 链式向前星 ---- poj 3268 : Silver Cow Party
Silver Cow Party Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 12674 Accepted: 5651 ...
随机推荐
- Oracle 同环比排除分母0
A 本期 B 同期(环期) 同比(环比) = (A-B)/B DECODE(NVL(B,0),0,0,ROUND(((A-B)/B),4)), --环比 DECODE(NVL(B),0,0,ROUN ...
- POJ2391:Ombrophobic Bovines(最大流+Floyd+二分)
Ombrophobic Bovines Time Limit: 1000MSMemory Limit: 65536K Total Submissions: 21660Accepted: 4658 题目 ...
- ionic改tab文字和icon图片的颜色
The official way would be: Change in your theme/variables.scss Active icon for tabs on android is: $ ...
- WebForm 在 Global.asax 中捕获全局异常
/// <summary> /// 捕获全局异常 /// </summary> /// <param name="sender">sender& ...
- C#中file类的应用
现在就其中几个常用的进行介绍: Create:一般使用此重载方法,File.Create (String) ,String是一个路径名,表示文件的完整路径,返回值是一个FileStream实例: Co ...
- [BZOJ3098]Hash Killer II解题报告
这天天气不错,hzhwcmhf神犇给VFleaKing出了一道题:给你一个长度为N的字符串S,求有多少个不同的长度为L的子串.子串的定义是S[l].S[l + 1].... S[r]这样连续的一段.两 ...
- [转]如何整理Linux磁盘碎片,竟与Windows的方式大不同 返回操作系统首页
Linux 系统永远不需要整理磁盘碎片的神话相信很多人都听说过.由于 Linux 采用了优秀的日志文件系统(ext2.ext3.ext4, btrfs等),在绝大多数情况下确实是不需要进行磁盘碎片整理 ...
- algorithm ch6 priority queque
堆数据结构的一个重要用处就是:最为高效的优先级队列.优先级队列分为最大优先级队列和最小优先级队列,其中最大优先级队列的一个应用实在一台分时计算机上进行作业的调度.当用堆来实现优先级队列时,需要在队中的 ...
- C/C++里的const(2)
对于如下几个语句,哪些定义相同?哪些定义不同?哪些数据可修改?哪些数据不可修改呢? const int a; int const a; const int *a; int *const a; int ...
- HDU2819(二分图匹配,记录过程)
Swap Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submis ...