The string APPAPT contains two PAT's as substrings. The first one is formed by the 2nd, the 4th, and the 6th characters, and the second one is formed by the 3rd, the 4th, and the 6th characters.

Now given any string, you are supposed to tell the number of PAT's contained in the string.

Input Specification:

Each input file contains one test case. For each case, there is only one line giving a string of no more than 105characters containing only P, A, or T.

Output Specification:

For each test case, print in one line the number of PAT's contained in the string. Since the result may be a huge number, you only have to output the result moded by 1000000007.

Sample Input:

APPAPT

Sample Output:

2
 #include<string>
#include<iostream>
#include<map> using namespace std; int numofP[];
int numofPA[];
int main()
{
string str;
getline(cin,str);
int P,A,T;
T = ;
int sumofP = ;
for(int i = ; i < str.length() ;++i)
{
if(str[i] == 'P')
++sumofP;
numofP[i] = sumofP;
} int sumofPA = ;
for(int i = ; i < str.length() ;++i)
{
if(str[i] == 'A')
{
sumofPA += numofP[i];
}
numofPA[i] = sumofPA;
} int sumofPAT = ;
for(int i = ; i < str.length() ;++i)
{
if(str[i] == 'T')
{
sumofPAT += numofPA[i];
sumofPAT = sumofPAT % ;//坑点
}
}
cout << sumofPAT <<endl;
return ;
}

1093. Count PAT's (25)的更多相关文章

  1. PAT (Advanced Level) Practise - 1093. Count PAT's (25)

    http://www.patest.cn/contests/pat-a-practise/1093 The string APPAPT contains two PAT's as substrings ...

  2. 1093. Count PAT’s (25)-统计字符串中PAT出现的个数

    如题,统计PAT出现的个数,注意PAT不一定要相邻,看题目给的例子就知道了. num1代表目前为止P出现的个数,num12代表目前为止PA出现的个数,num123代表目前为止PAT出现的个数. 遇到P ...

  3. 【PAT甲级】1093 Count PAT's (25 分)

    题意: 输入一行由大写字母'P','A','T',组成的字符串,输出一共有多少个三元组"PAT"(相对顺序为PAT即可),答案对1e9+7取模. AAAAAccepted code ...

  4. PAT甲级 1093 Count PAT‘s (25 分) 状态机解法

    题目 原题链接 The string APPAPT contains two PAT's as substrings. The first one is formed by the 2nd, the ...

  5. PAT (Advanced Level) 1093. Count PAT's (25)

    预处理每个位置之前有多少个P,每个位置之后有多少个T. 对于每个A,贡献的答案是这个A之前的P个数*这个A之后T个数. #include<cstdio> #include<cstri ...

  6. pat1093. Count PAT's (25)

    1093. Count PAT's (25) 时间限制 120 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CAO, Peng The strin ...

  7. PAT甲级——1093 Count PAT's (逻辑类型的题目)

    本文同步发布在CSDN:https://blog.csdn.net/weixin_44385565/article/details/93389073 1093 Count PAT's (25 分)   ...

  8. PAT 1093 Count PAT's[比较]

    1093 Count PAT's (25 分) The string APPAPT contains two PAT's as substrings. The first one is formed ...

  9. 1093 Count PAT's(25 分)

    The string APPAPT contains two PAT's as substrings. The first one is formed by the 2nd, the 4th, and ...

随机推荐

  1. JdbcTemplate 、NamedParameterJdbcTemplate、SimpleJdbcTemplate的区别

    一.JdbcTemplate 首先在配置文件中设置数据源 <bean id="dataSource" class="org.springframework.jdbc ...

  2. state/ui-router

    state/ui-router 一个状态对应于一个页面位置 通过定义controller.template和view等属性,来定义指定位置的用户界面和界面行为 通过嵌套的方式来解决页面中的一些重复出现 ...

  3. hdu 3938 并查集

    思路:这题的出题人是不是语文不行啊,题目意思说不清楚. 知道是求存在路径的点对数后,用并查集每次记录集合中点的数目,很容易就解决了. #include<set> #include<c ...

  4. 基于Qt的Tcp协议的流程图

    TCP(Transmission Control Protocol传输控制协议)是一种面向连接的.可靠的.基于字节流的传输层通信协议.在qt中,Tcp协议主要是用QTcpServer和QTcpSock ...

  5. 话说Centos下nginx,php,mysql以及phpmyadmin的配置

    大话centos下部署phalcon框架 Centos还是ubuntu? 当我沿用这个标题的时候,心里在想"我能说我之前用的windows吗?",windows下xampp,wam ...

  6. 瀑布流布局--jQuery写法

    HTML <div id="main"> <div class="box"> <div class="pic" ...

  7. 符号渲染篇——Symbol

    Symbol 是对 Graphic 对象进行符号样式设置的接口,所有符号样式类都实现了 Symbol 接口. 1.PictureMarkerSymbolPictureMarkerSymbol 是对于点 ...

  8. SourceTree基本操作

    下载地址:https://www.sourcetreeapp.com 1.从克隆远程仓库 2.填写git地址 3.克隆成功后会来点如下界面,点击testGitHub 4.scourceTree管理界面 ...

  9. 【原创】Oracle函数中对于NO_DATA_FOUND异常处理的研究

    一直以来有一个困惑,一直没解决,昨天一哥们问我这个问题,决心弄清楚,终于得到了答案.先看下面这个函数: create or replace function fn_test(c_xm varchar) ...

  10. Xcode中如何更改Bundle identifier

    1.如图所示,更改Info.plist 中的Bundle identifier