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. CentOS6.5下用yum安装 git

    cd /etc/yum.repos.d/ wget http://geekery.altervista.org/geekery-el6-x86_64.repo 2. 到http://packages. ...

  2. 【转】使用nmon监控suse或linux操作系统

    目的:使用nmon监控操作系统的内存,CPU等症状 nmon介绍:nmon 工具可以为AIX和Linux性能专家提供监视和分析性能数据的功能,其中包括CPU,内存,IO,free空间,页面空间页面速度 ...

  3. ankhSVN安装后,VS2010使用

    Tool->option->Source control->plug-in selection,选择ankhSVN AnkhSvn-2.5.12478.zip

  4. css优先机制

    样式的优先级 (外部样式)External style sheet <(内部样式)Internal style sheet <(内联样式)Inline style (内部样式就是css写在 ...

  5. MongoDB - The mongo Shell, Write Scripts for the mongo Shell

    You can write scripts for the mongo shell in JavaScript that manipulate data in MongoDB or perform a ...

  6. Part 92 Significance of Thread Join and Thread IsAlive functions

    Thread.Join & Thread.IsAlive functions Join blocks the current thread and makes it wait until th ...

  7. CSV文件导入到SQL Server表中

    USE 数据库名BULK Insert dbo.表名From 'c:\CSV文件名.csv'  WITH (   FIELDTERMINATOR = ',',   ROWTERMINATOR = '\ ...

  8. DataGridView 操作

    //dataGridView 删除选中行 int num = dataGridView2.SelectedRows.Count; ) { DataGridViewRow r = dataGridVie ...

  9. C#颜色 转换

    C#Winform 使用16进制颜色 var color = ColorTranslator.FromHtml("#eeeeee");

  10. 转载:Github 简明教程

    如果你是一枚Coder,但是你不知道Github,那么我觉的你就不是一个菜鸟级别的Coder,因为你压根不是真正Coder,你只是一个Code搬运工. 但是你如果已经在读这篇文章了,我觉的你已经知道G ...