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. JAX-WS开发WebService程序

    近来公司里要用的到WebService做开发,所以就自己学习了一下,刚开始感觉挺难的,但是真正学会以后,原来这么简单. 今天把这些东西哦记下来,以便日后的复习. 我来介绍一下我的开发环境:Eclips ...

  2. Linux Bash Shell学习笔记

    参数扩展: 1.被名称引用的参数称作变量2.被数字引用的参数称作位置参数3.被特定符号引用的参数具有特殊的含义和用途,被称作Bash的特殊内部变量引用. 基本参数扩展:字符$会引导参数扩展.大括号是可 ...

  3. apache2.4的安装与卸载

    安装sudo apt-get install apache2,这不是源码安装的方式,产生的apache地址在/etc/apache2,配置文件是apache2.conf如果浏览器输入127.0.0.1 ...

  4. amoeba实现MySQL读写分离

    amoeba实现MySQL读写分离 准备环境:主机A和主机B作主从配置,IP地址为192.168.131.129和192.168.131.130,主机C作为中间件,也就是作为代理服务器,IP地址为19 ...

  5. Tarjan 离线算法LCA

    #include<map> #include<set> #include<cmath> #include<queue> #include<cstd ...

  6. 【转】Oracle 中的 TO_DATE 和 TO_CHAR 函数 日期处理

    Oracle 中的 TO_DATE 和 TO_CHAR 函数oracle 中 TO_DATE 函数的时间格式,以 2008-09-10 23:45:56 为例 格式 说明 显示值 备注 Year(年) ...

  7. Differential Geometry之第五章曲面的内蕴几何学

    第五章.曲面的内蕴几何学 1.曲面的等距变换 2.曲面的协变微分 协变微分: 3.测地曲率与测地线 4.测地坐标系 4.1.测地平行坐标系 4.2.测地极坐标系和法坐标系 5.Gauss-Bonnet ...

  8. Matlab之画图

    1.设置对数坐标 set(gca,'XScale','log','YScale','log'); 2.加网格 grid on; 3.加log对齐网格 set(gca,'XScale','log','Y ...

  9. Mac下kernel_task占用大量CPU怎么办?

    我们都知道要想让电脑运行的快速,那么就要尽量的保持内存和CPU的充足.不过一些MAC用户发现MAC系统中的Kernel_task会占用大量的CPU,导致电脑发热变卡.这个问题该怎么解决呢? 具体操作步 ...

  10. iOS - 数组(NSArray)

    1. 数组的常用处理方式 //--------------------不可变数组 //1.数组的创建 NSString *s1 = @"zhangsan"; NSString *s ...