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 1 characters containing only PA, 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<cstdio>
#include<cstring>
const int maxn = ;
const int MOD = ;
char str[maxn];
int leftNumP[maxn] = {};
int main(){
fgets(str,maxn,stdin);
int len = strlen(str);
for(int i = ; i < len; i++){
if(i > ){
leftNumP[i] = leftNumP[i-];
}
if(str[i] == 'P'){
leftNumP[i]++;
}
}
int ans = ,rightNumT = ;
for(int i = len - ; i >= ; i--){
if(str[i] == 'T'){
rightNumT++;
}else if(str[i] == 'A'){
ans = (ans + rightNumT * leftNumP[i]) % MOD;
}
}
printf("%d\n",ans);
return ;
}

最新文章

  1. 【Web动画】SVG 实现复杂线条动画
  2. 我的.NET自学之路
  3. Linux下搭建DNS服务器
  4. Spring(四)Bean注入方试
  5. CSS3实现10种Loading效果
  6. Visual Studio 2015 与GitLab 团队项目与管理【2】
  7. jqgrid 中设置列不排序
  8. openwrt 更改 debug 等级(hostapd)
  9. JAVA基础——Arrays工具类十大常用方法
  10. CvIntHaarClassifier
  11. 谷歌内核浏览器 iframe内容的 tab切换 滚动条消失
  12. MFC下用sdl 显示bmp、rgb、yuv
  13. [ExtJS5学习笔记]第七节 Extjs5的组件components及其模板事件方法学习
  14. .net文件上传默认限制了大小4M
  15. python 线程/线程锁/信号量
  16. javap浅析-书籍第3章的手写稿样稿
  17. git clean(转载)
  18. csu oj 1341 string and arrays
  19. Meandering Through the Maze of MFC Message and Command Routing MFC消息路由机制分析
  20. Spring事务异常rollback-only

热门文章

  1. uoj problem 31 猪猪侠再战括号序列
  2. JUI web企业应用框架 http://jui.org/
  3. Mybatis下面的MapperScannerConfigurer 扫描器
  4. winfrom实现控件全屏效果
  5. python 基础 字典 增删改查
  6. 关于cin
  7. Linux性能测试工具-UnixBench--安装以及结果分析
  8. Packet for query is too large
  9. Java探索之旅(7)——对象的思考
  10. 菜鸟攻城狮2(JAVA开发环境)