PAT_A1093#Count PAT's
Source:
Description:
The string
APPAPT
contains twoPAT
'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 1 characters containing only
P
,A
, orT
.
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
Keys:
- 模拟题
Code:
#include <cstdio>
#include <string>
#include <iostream>
using namespace std;
const int MOD = ; int main()
{
#ifdef ONLINE_JUDGE
#else
freopen("test.txt", "r", stdin);
#endif string s;
cin >> s;
long long t=, p=, a=;
for(int i=s.size()-; i>=; i--)
{
if(s[i]=='P') p = (p+a)%MOD;
else if(s[i]=='A') a = (a+t)%MOD;
else t = (t+)%MOD;
}
printf("%lld\n", p); return ;
}
PAT_A1093#Count PAT's的更多相关文章
- PAT1093: Count PAT's
1093. Count PAT's (25) 时间限制 120 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CAO, Peng The strin ...
- PAT 1093 Count PAT's[比较]
1093 Count PAT's (25 分) The string APPAPT contains two PAT's as substrings. The first one is formed ...
- pat1093. Count PAT's (25)
1093. Count PAT's (25) 时间限制 120 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CAO, Peng The strin ...
- PAT甲级——1093 Count PAT's (逻辑类型的题目)
本文同步发布在CSDN:https://blog.csdn.net/weixin_44385565/article/details/93389073 1093 Count PAT's (25 分) ...
- 1093. Count PAT's (25)
The string APPAPT contains two PAT's as substrings. The first one is formed by the 2nd, the 4th, and ...
- 1093. Count PAT's
The string APPAPT contains two PAT's as substrings. The first one is formed by the 2nd, the 4th, and ...
- 1093. Count PAT’s (25)-统计字符串中PAT出现的个数
如题,统计PAT出现的个数,注意PAT不一定要相邻,看题目给的例子就知道了. num1代表目前为止P出现的个数,num12代表目前为止PA出现的个数,num123代表目前为止PAT出现的个数. 遇到P ...
- 1093 Count PAT's(25 分)
The string APPAPT contains two PAT's as substrings. The first one is formed by the 2nd, the 4th, and ...
- PAT (Advanced Level) Practise - 1093. Count PAT's (25)
http://www.patest.cn/contests/pat-a-practise/1093 The string APPAPT contains two PAT's as substrings ...
随机推荐
- 测开之路五十六:实现类似unittest的断言
import inspect class Case(object): """ 实现断言 """ def __init__(self): se ...
- 测开之路四十九:用Django实现扑克牌游戏
用Django实现和之前flask一样的扑克牌游戏 项目结构 html <!DOCTYPE html><html lang="en"><head> ...
- 测开之路二十九:Flask基础之jinja2模板
中文文档:http://docs.jinkan.org/docs/jinja2/ 与静态资源一样,Flask默认的模板目录名为templates,如果有需要的话和static一样,要在初始化的时候声明 ...
- latex 查找缺失的库文件
app-portage/pfl contains a program to search in an online database for a Gentoo package containing a ...
- QTP read or write XML file
'strNodePath = "/soapenv:Envelope/soapenv:Body/getProductsResponse/transaction/queryProducts/qu ...
- CSS深入理解float
初衷:图片环绕效果 1.会使父元素高度塌陷 2.包裹性 3.让元素block化 4.去空格化 5.清除浮动 .clearfix::after{ content:""; disp ...
- Loadrunner实现多台测试机负载时可能遇到的难题
压测机安装的loadrunner版本为11.0 压测机器的操作系统是windows server 2016 所有的负载机器操作系统和压侧机器是一样的,都是windows server 2016 Err ...
- 【转】在配置静态IP的时候遇到 :bringing up interface eth0 : error unknown connection
首先这是动态ip配置成功的结果 接下来切换到root用户来配置静态的 按照静态ip的配置方法配置好文件后(具体过程这里就不多加说明) 然后保存退出 当我们重启网卡的时候问题来了(因为本人有点强迫症,多 ...
- Python3学习笔记——异常处理
#!/usr/bin/env python # 1.异常处理 try: # 主要执行的代码 except IndexError as e: # 对于某些错误需要特殊处理的,可以对特殊错误进行捕捉 pr ...
- 卸载 Bash On Ubuntu On Windows
1.打开cmd,输入lxrun /uninstall /full,然后根据提示输入y即可开始卸载. 已失效