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 ...
随机推荐
- APP测试功能点
1.使用APP时手机耗电情况 2.APP占用手机内存 3.APP在不同网络下的使用情况(WiFi/4G/3G/2G) 4.APP安装包大小 5.APP流量消耗 6.APP支持系统版本(android, ...
- C语言博客作业12
一.我学到的内容 二.我的收获 * https://www.cnblogs.com/asd123456/ * 我的收获:通过这一个学期的学习,我一共完成了11次作业,由最开始的第一次作业https:/ ...
- 网站设置成代理后,chrome chrome HTTP ERROR 502
在阿里云上设置CNAME代理后,发现www.xxxx.com出现502,但是http://xxxx.com却可以访问. ping了一下都可以,网上搜了搜原来和nginx.conf配置有关 配置如下,上 ...
- C++中的智能指针类模板
1,智能指针本质上是一个对象,这个对象可以像原生的指针一样使用,因为智能指 针相关的类通过重载的技术将指针相关的操作符都进行了重载,所以智能指针对象可以像原生指针一样操作,今天学习智能指针类模板,通过 ...
- websocket简单实现聊天
1.多人聊天 from geventwebsocket.handler import WebSocketHandler # 请求处理WSGI HTTP from geventwebsocket.ser ...
- vue项目的脚手架
> cnpm i @vue/cli@3 -g > vue create myapp * 选择 Manually select features ----- 自选预设文件 * 选择 vue ...
- getCss函数
var box=document.getElementById('box'); function getCss(curEle,attr){ var val=null; //去单位 var reg=/^ ...
- 2019-1-28-WPF-高性能笔
title author date CreateTime categories WPF 高性能笔 lindexi 2019-1-28 14:21:5 +0800 2018-2-13 17:23:3 + ...
- 转载:java面试题(一)
1.面向对象的特征有哪些方面? 答:面向对象的特征主要有以下几个方面: - 抽象:抽象是将一类对象的共同特征总结出来构造类的过程,包括数据抽象和行为抽象两方面.抽象只关注对象有哪些属性和行为,并不关注 ...
- IIS配置Windows防火墙允许外部访问
控制面板-Windows防火墙-高级设置-入站规则 在入站规则窗口中找到“BranchCache内容检索(HTTP-In)”选项并启用此规则. 这时候远程用户通过网站地址即可访问站点程序. 但是如果远 ...