1093. Count PAT's (25)
来源:互联网 发布:java log4j 实例 编辑:程序博客网 时间:2024/06/05 00:17
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 105 characters 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:APPAPTSample Output:
2
#include<cstdio>#include<iostream>using namespace std;int main(){ char c; int nump=0,numpa=0,numpat=0; while((c=getchar())!='\n') { if (c=='P') nump++; else if (c=='A') numpa=(numpa+nump)%1000000007; else numpat=(numpat+numpa)%1000000007; } printf("%d",numpat); return 0;}
阅读全文
0 0
- 1093. Count PAT's (25)
- 1093. Count PAT's (25)
- 1093. Count PAT's (25)
- 1093. Count PAT's (25)
- 1093. Count PAT's (25)
- 1093. Count PAT's (25)
- 1093. Count PAT's (25)
- 1093. Count PAT's (25)
- 1093. Count PAT's (25)
- 1093. Count PAT's (25)
- 1093. Count PAT's (25)
- 1093. Count PAT's (25)
- 1093. Count PAT's (25)
- 1093. Count PAT's (25)
- 1093. Count PAT's (25)
- 1093. Count PAT's (25)
- 1093. Count PAT's (25)
- 1093. Count PAT's (25)
- 数据类型转换之 CString与int
- Ruby on Rails安装过程,煞费苦心
- Rails核心组件
- HDOJ 2039 三角形
- 创建一个Rails项目
- 1093. Count PAT's (25)
- 解决Ubuntu的root账号无法登录SSH问题-Permission denied, please try again.
- linux命令:返回上一次目录
- mysql-ubuntu彻底卸载mysql
- Ubuntu系统下MySQL开启远程连接
- 实现插入排序和希尔排序——题集(十五)
- Ubuntu默认防火墙安装、启用、配置、端口、查看状态相关信息
- Windows定时关机
- 集训第一天(2017/7/31):深度优先搜索dfs专项练习