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 ...
随机推荐
- js 判断对象的长度
Object.size = function(obj) { var size = 0, key; for (key in obj) { if (obj.hasOwnProperty(key)) siz ...
- <读书笔记>《Web前端开发最佳实践》
P77 P89 CSS Reset P94 给CSS样式定义排序 排序工具:CSScomb P97 什么是CSS的权重?权重是指选择符的优先级 P100 工具:Sass Less P101 框架 ...
- 详解JavaScript数组过滤相同元素的5种方法
详解JavaScript数组过滤相同元素的5种方法:https://www.jb51.net/article/114490.htm
- Flink从socket读取数据sink到redis
package com.lin.flink.stream.customPartition; import org.apache.flink.api.common.functions.MapFuncti ...
- money (dp)
牛客网暑假训练第二场D题: 链接:https://www.nowcoder.com/acm/contest/140/D来源:牛客网 题目描述 White Cloud has built n store ...
- java反射-学习
使用Java反射机制可以在运行时期获取Java类的信息,可获取以下相关的内容: Class对象 类名 修饰符 包信息 父类 实现的接口 构造器 方法 变量 注解 简单的反射例子: 1.获取class对 ...
- 第四节 RabbitMQ在C#端的应用-客户端连接
原文:第四节 RabbitMQ在C#端的应用-客户端连接 版权声明:未经本人同意,不得转载该文章,谢谢 https://blog.csdn.net/phocus1/article/details/87 ...
- k8s之ingress-nginx部署一直提示健康检查10254端口不通过问题就处理
之前部署了一套k8s集群,但是到部署ingress-nginx的时候,一直提示10254端口拒绝不通:如下图. 这是因为我之前装的是docker1.17.默认的驱动是systemd.因为systemd ...
- js非布尔值的与(&&)与或(||)运算
/** * 非布尔值的与(&&)与或(||)运算 * 1.先将其转换成布尔值再做运算,并且返回原值 * 2.与(&&)运算: * a.如果第一个值为true,则返回第二 ...
- Linux学习笔记之认识与学习Bash
什么是shell:shell是一个翻译器,将所敲的命令翻译成CPU能理解的语言,之后CPU再去执行,CPU执行后返回给shell,shell再翻译成我们所能理解的语言并显示:终端并不是shell,而是 ...