1093. Count PAT's (25)【计数】——PAT (Advanced Level) Practise
来源:互联网 发布:exp数据库表结构导出 编辑:程序博客网 时间:2024/04/28 09:32
题目信息
1093. Count PAT’s (25)
时间限制120 ms
内存限制65536 kB
代码长度限制16000 B
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 10^5 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:
APPAPT
Sample Output:
2
解题思路
统计
AC代码
#include <cstdio>#define MOD 1000000007int ch;int p, a, t, c;int main(){ long long cnt = 0; while ((ch = getchar()) && ch != '\n'){ if (ch == 'P') { ++p; }else if (ch == 'A') { c += p; }else if (ch == 'T') { ++t; cnt = (cnt + c)%MOD; } } printf("%lld", cnt); return 0;}
- 1093. Count PAT's (25)【计数】——PAT (Advanced Level) Practise
- PAT (Advanced Level) Practise 1093 Count PAT's (25)
- PAT (Advanced Level) Practise 1093 Count PAT's (25)
- 【PAT】【Advanced Level】1093. Count PAT's (25)
- 1055. The World's Richest (25)【排序】——PAT (Advanced Level) Practise
- 1003. Emergency (25)——PAT (Advanced Level) Practise
- 1010. Radix (25)——PAT (Advanced Level) Practise
- 1016. Phone Bills (25)——PAT (Advanced Level) Practise
- 1020. Tree Traversals (25)——PAT (Advanced Level) Practise
- 1029. Median (25)【排序】——PAT (Advanced Level) Practise
- 1032. Sharing (25)【链表】——PAT (Advanced Level) Practise
- 1070. Mooncake (25)【贪心】——PAT (Advanced Level) Practise
- [PAT] (Advanced Level) Practise
- PAT (Advanced Level) Practise
- PAT (Advanced Level) Practise
- PAT (Advanced Level) Practise
- PAT (Advanced Level) Practise
- PAT (Advanced Level) Practise
- 1092. To Buy or Not to Buy (20)【水题】——PAT (Advanced Level) Practise
- C++_FatMouse' Trade(贪心)
- 使用.NET Framework提供的InstallUtil.exe安装Windows服务安装时遇到的2种常见错误
- Android并发编程之图文解析volatile关键字
- Lucene 初探
- 1093. Count PAT's (25)【计数】——PAT (Advanced Level) Practise
- 说反话
- 第十周项目5——摩托车继承自行车和机动车
- spring源码解读
- QT-如何添加资源文件
- 字符串的反转
- Git与Repo入门
- Android并发编程之白话文详解Future,FutureTask和Callable
- 8086汇编语言课程设计一