PAT 甲级 1093. Count PAT's (25)
来源:互联网 发布:logitech g502 mac 编辑:程序博客网 时间:2024/05/19 17:03
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 <algorithm>#include <queue>#include <cstring>#include <iostream>#include <vector>#include <string>using namespace std;int main() {string s;cin >> s;int len = s.length(), result = 0, cntp = 0, cntt = 0;for (int i = 0; i < len; i++) {if (s[i] == 'T')cntt++;}for (int i = 0; i < len; i++) {if (s[i] == 'P') cntp++;if (s[i] == 'T') cntt--;if (s[i] == 'A') result = (result + (cntp*cntt) % 1000000007) % 1000000007;}cout << result << endl;return 0;}
阅读全文
0 0
- PAT甲级1093. Count PAT's (25)
- PAT 甲级 1093. Count PAT's (25)
- 1093. Count PAT’s (25)-PAT甲级真题
- [转]PAT甲级练习1093. Count PAT's (25)
- 1040. 有几个PAT(25)PAT乙级&&1093. Count PAT's (25) PAT甲级
- PAT 1093. Count PAT's (25)
- PAT A 1093. Count PAT's (25)
- pat 1093. Count PAT's (25)
- PAT 1093. Count PAT's (25)
- 【PAT】1093. Count PAT's (25)
- pat 1093. Count PAT's (25)
- PAT 1093. Count PAT's (25)
- PAT 1093. Count PAT's (25)(有意思)
- PAT--1093. Count PAT's (25)
- PAT A 1093. Count PAT's (25)
- PAT-A 1093. Count PAT's (25)
- PAT 1093. Count PAT's (25)
- PAT-A-1093. Count PAT's (25)
- Codeforces Round #438 B Race Against Time(模拟)
- window系统安装杂笔
- 前端之路随笔小记——属性:lang VS charset
- PAT 甲级 1091. Acute Stroke (30)
- 一点 · 线性表
- PAT 甲级 1093. Count PAT's (25)
- 前端的window.location
- java实现linux中gzip压缩解压缩算法:byte[]字节数组,文件,字符串,数据流的压缩解压缩
- linux内核驱动模块开发步骤及实例入门介绍
- 51 nod 苹果曼和树
- QT自定义控件之圆形头像的实现
- Codeforces Round #438 C Qualification Rounds(暴力+位运算)
- codevs 1026 逃跑的拉尔夫 BFS
- 3294: [Cqoi2011]放棋子