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. maven 本地仓库nexus的安装

    首先我们将nexus下载下来:http://www.sonatype.org/downloads/nexus-latest-bundle.zip 下载下来之后我们将文件解压,解压完成之后,我们首先,打 ...

  2. iOS 6编程Cookbook(影印版)

    <iOS 6编程Cookbook(影印版)> 基本信息 原书名:iOS 6 Programming Cookbook 作者: Vandad Nahavandipoor 出版社:东南大学出版 ...

  3. svn配置

    svn配置 subverson.conf <Location /svn> DAV svn SVNListParentPath on SVNParentPath /var/repo Auth ...

  4. oracle-SQL语言基础-事务控制命令命令

    事务控制命令命令 COMMITROLLBACKSAVEPOINTSET TRANSACTION 当第一条可执行的SQL语句开始执行,数据库事务就开始.随着下面任一事件发生,数据库事务结束:执行COMM ...

  5. Learn Vim

    Vim Note 很早就知道vim是一个很强大的编辑器,也用了很久.不过没有系统的总结过,这次就写个笔记方便以后看看(本文在vim下编辑完成) 第一印象 打开vim第一感觉就是无从下手,相信大多数人和 ...

  6. CF Soldier and Badges (贪心)

    Soldier and Badges time limit per test 3 seconds memory limit per test 256 megabytes input standard ...

  7. Set集合——HashSet、TreeSet、LinkedHashSet(2015年07月06日)

    一.Set集合不同于List的是: Set不允许重复 Set是无序集合 Set没有下标索引,所以对Set的遍历要通过迭代器Iterator 二.HashSet 1.HashSet由一个哈希表支持,内部 ...

  8. Javascript delete 引用类型对象

    很少使用javascript的delete,最近因为一个小bug发现删除引用类型对象的时候有一点不同.如下面例子: var testVar = { a : { test : 1 } }, test1 ...

  9. ASP.NET中后台注册js脚本攻略(转)

    用Page.ClientScript.RegisterClientScriptBlock 和Page.ClientScript.RegisterStartupScript:区别:   1.使用Page ...

  10. 使用jquery插件报错:TypeError:$.browser is undefined的解决方法

    关于$.browser browser就是用来获取浏览器基本信息的. jQuery 从 1.9 版开始,移除了 $.browser 和 $.browser.version , 取而代之的是 $.sup ...