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 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)的更多相关文章
- 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 ...
 - 1093. Count PAT’s (25)-统计字符串中PAT出现的个数
		
如题,统计PAT出现的个数,注意PAT不一定要相邻,看题目给的例子就知道了. num1代表目前为止P出现的个数,num12代表目前为止PA出现的个数,num123代表目前为止PAT出现的个数. 遇到P ...
 - 【PAT甲级】1093 Count PAT's (25 分)
		
题意: 输入一行由大写字母'P','A','T',组成的字符串,输出一共有多少个三元组"PAT"(相对顺序为PAT即可),答案对1e9+7取模. AAAAAccepted code ...
 - PAT甲级 1093 Count PAT‘s (25 分)  状态机解法
		
题目 原题链接 The string APPAPT contains two PAT's as substrings. The first one is formed by the 2nd, the ...
 - PAT (Advanced Level) 1093. Count PAT's (25)
		
预处理每个位置之前有多少个P,每个位置之后有多少个T. 对于每个A,贡献的答案是这个A之前的P个数*这个A之后T个数. #include<cstdio> #include<cstri ...
 - pat1093. Count PAT's (25)
		
1093. Count PAT's (25) 时间限制 120 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CAO, Peng The strin ...
 - PAT甲级——1093 Count PAT's (逻辑类型的题目)
		
本文同步发布在CSDN:https://blog.csdn.net/weixin_44385565/article/details/93389073 1093 Count PAT's (25 分) ...
 - PAT 1093 Count PAT's[比较]
		
1093 Count PAT's (25 分) The string APPAPT contains two PAT's as substrings. The first one is formed ...
 - 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 ...
 
随机推荐
- centos下查看rpm包安装位置
			
1.如何安装rpm软件包 rpm -ivh your-package.rpm其中your-package.rpm是你要安装的rpm包的文件名,一般置于当前目录下. 2.如何卸载rpm软件包使用命令 r ...
 - iOS - 第三方框架 - AFN
			
#5.AFNetworking 2.6使用方法 >2.6版本 支持 iOS7以上,而且支持NSURLConnectionOperation >3.0版本 支持 iOS7以上 NSURLCo ...
 - Precompile Prefix file(.pch文件)
			
参考资料: http://blog.csdn.net/lwjok2007/article/details/46385595 http://www.tuicool.com/articles/beURbe ...
 - 《MFC游戏开发》笔记十 游戏中的碰撞检测进阶:地图类型&障碍物判定
			
本系列文章由七十一雾央编写,转载请注明出处. http://blog.csdn.net/u011371356/article/details/9394465 作者:七十一雾央 新浪微博:http:// ...
 - 在项目中使用SQLite数据库小结
			
------------------------------------------------------------------------推荐: - VS2012 使用 1.0.84 版的库 - ...
 - Problem:Minesweeper Master
			
Google code jam Qualification Round 2014 题目链接:https://code.google.com/codejam/contest/dashboard?c=29 ...
 - Umbraco(5)-Creating Master Template Part 1(翻译文档)
			
原文地址:http://www.ncloud.hk/%E6%8A%80%E6%9C%AF%E5%88%86%E4%BA%AB/umbraco5-creating-master-template-par ...
 - 剑指Offer44 扑克牌的顺子
			
/************************************************************************* > File Name: 44_Contin ...
 - hdu1331 按着题目的公式直接写
			
#include<cstdio> #include<iostream> #include<cstring> #include<algorithm> #d ...
 - IOS的一些尺寸
			
iPhone或iTouch的宽为320像素,高为480像素, 状态栏高为20像素 toobar高为44像素 tabbar高为49像素 导航栏高为44像素 iphone分辨率参数 型号 屏幕尺寸 分辨率 ...