PAT_A1093#Count PAT's
Source:
Description:
The string
APPAPTcontains 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 ...
随机推荐
- Python中多线程的阻塞问题
在使用Queue模块+多线程模拟生产者+消费者问题时,遇到了一个小问题,现在记录下来.供可能会遇到类似问题的初学者们参考. 该问题的完整参考代码如下.主要实现了以下的功能:在一个线程中,开启生产者模式 ...
- Java + selenium 元素定位(2)之By LinkText/PartialLinkText
本章介绍的两种方法都是对于网页上的文字链接的定位操作.根据名字,我们就可以看出来,这两者其实很相似,那么他们的不同在哪里呢. By LinkText()方法,是对一个的网页超链接,我们所需要输入的关键 ...
- C#后台获取根路径
C#后台获取当前系统根路径: string absoluteurl = Context.Request.Url.AbsoluteUri.Replace(Context.Request.RawUrl, ...
- 【计算机网络】两个网络模型——OSI参考模型和TCP/IP模型
计算机网络 两个网络模型 计算机网络模型 分层机制----规划通讯细节 层与层之间之间是独立的.屏蔽的,下层为上层提供服务. 一些概念 实体: 任何发送/接收信息的软件/硬件进程. 对等层: 两个不同 ...
- Spring 常犯的十大错误,打死都不要犯!
原文:https://www.toptal.com/spring/top-10-most-common-spring-framework-mistakes 作者:Toni Kukurin,译者:万想 ...
- matplotlib系列——饼图
import matplotlib.pyplot as plt import numpy as np import matplotlib import sys 1.主体函数 #饼图 def die(l ...
- 中文字符集编码unicode,gb2312,cp936,GBK,GB18030介绍
概要: UTF-8的一个特别的好处是它与ISO- 8859-1完全兼容,可以表示世界上所有的字符,汉字通常用3个字节来表示.GB2312的code page是CP20936.GBK的code page ...
- bzoj2582 [Usaco2012Jan]Bovine Alliance
[Usaco2012Jan]Bovine Alliance Time Limit: 2 Sec Memory Limit: 128 MB Description Bessie and her bovi ...
- python字符串方法学习笔记
# 一.字符串大小写转换# 字符串首字符大写print("hello world".capitalize())# 将字符串变为标题print("hello WORLD&q ...
- Bootstrap 网页实例
代码: <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <met ...