1093
来源:互联网 发布:迅雷7精简优化版 编辑:程序博客网 时间:2024/06/06 17:22
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 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 <iostream>#include <cstdio>#include <cstring>using namespace std;const int DIV = 1000000007;const int N = 100005;char str[N];int main(void){scanf("%s", str);int num1 = 0, num2 = 0, num3 = 0;int length = strlen(str);for (int i = 0; i < length; ++i){if (str[i] == 'P')++num1;else if (str[i] == 'A')num2 = (num2 + num1) % DIV;elsenum3 = (num3 + num2) % DIV;}printf("%d\n", num3);return 0;}
0 0
- 1093
- 1093
- #1093
- problem 1093
- zoj 1093
- hdu 1093
- ZJU-1093
- HDOJ 1093
- ZOJ 1093
- hdu 1093
- 水题 1093
- sicily 1093
- ZOJ-1093
- sicily 1093
- hihocoder 1093
- mysql 1093
- hihocoder #1093
- 交大1093
- NFS ROOT 启动内核的配置(UBoot)
- 因一段JavaScript代码引发的闲扯
- syslog 服务器过程详解
- OC关于NSFileHandle的解析
- ios开发之视频播放
- 1093
- matlab语言,实现了对高光谱遥感图像的读取并做主成分分析,将结果按贡献率大小顺序排列并显示出来
- Java安全结构“沙盒”模型4个组成部分
- HDOJ 5383 Yu-Gi-Oh! 最大费用最大流
- IPC - POSIX和System V比较
- SAP 金税接口增强 BADI
- zookeeper 大量连接断开重连原因排查
- WAS缓存问题
- That Nice Euler Circuit (好看的一笔画)