PAT-A-1093. Count PAT's (25)
来源:互联网 发布:linux 502端口映射 编辑:程序博客网 时间:2024/05/19 19:55
1093. Count PAT's (25)
时间限制
120 ms
内存限制
65536 kB
代码长度限制
16000 B
判题程序
Standard
作者
CAO, Peng
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:APPAPTSample Output:
2
#include<iostream>#include<cstdio>#include<string.h>using namespace std;char a[100010];int main(){ cin >> a; int numt = 0; int numat = 0; int numpat = 0; int len = strlen(a); for (int i = len - 1; i >= 0; i--) { if (a[i] == 'T') numt++; else if (a[i] == 'A') numat = (numat + numt) % 1000000007; else numpat = (numpat + numat) % 1000000007; } cout << numpat << endl; system("pause"); return 0;}
0 0
- PAT A 1093. Count PAT's (25)
- PAT A 1093. Count PAT's (25)
- PAT-A 1093. Count PAT's (25)
- PAT-A-1093. Count PAT's (25)
- Pat(A) 1093. Count PAT's (25)
- PAT-A 1093. Count PAT's
- 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--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)
- 神经网络的简介
- java内存模型
- 全新手在linux上安装jdk
- Java CAS 和ABA问题
- numpy 高阶函数 —— np.histogram
- PAT-A-1093. Count PAT's (25)
- Docker基础入门及示例
- 用idea搭建SSH框架--校内测试
- Sql Server 安全性实验
- 客观世界的音乐和人的关系
- 用c语言编写小游戏:贪吃蛇
- Linux防火墙iptables
- 杨辉三角
- 极光推送开发第二弹——极光推送API