【PAT甲级】1093 Count PAT's (25 分)
题意:
输入一行由大写字母'P','A','T',组成的字符串,输出一共有多少个三元组"PAT"(相对顺序为PAT即可),答案对1e9+7取模。
AAAAAccepted code:
#define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
const long long mod = 1e9+;
string s;
long long nump[],numpa[];
long long sum[];
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin>>s;
int n=s.size();
for(int i=;i<n;++i){
nump[i]=nump[i-];
if(s[i]=='P'){
++nump[i];
nump[i]%=mod;
}
numpa[i]=numpa[i-];
if(s[i]=='A'){
numpa[i]+=nump[i];
numpa[i]%=mod;
}
sum[i]=sum[i-];
if(s[i]=='T'){
sum[i]+=numpa[i];
sum[i]%=mod;
}
}
cout<<sum[n-];
return ;
}
【PAT甲级】1093 Count PAT's (25 分)的更多相关文章
- PAT甲级——1093 Count PAT's (逻辑类型的题目)
本文同步发布在CSDN:https://blog.csdn.net/weixin_44385565/article/details/93389073 1093 Count PAT's (25 分) ...
- PAT甲级 1093 Count PAT‘s (25 分) 状态机解法
题目 原题链接 The string APPAPT contains two PAT's as substrings. The first one is formed by the 2nd, the ...
- PAT 甲级 1040 Longest Symmetric String (25 分)(字符串最长对称字串,遍历)
1040 Longest Symmetric String (25 分) Given a string, you are supposed to output the length of the ...
- PAT 甲级 1083 List Grades (25 分)
1083 List Grades (25 分) Given a list of N student records with name, ID and grade. You are supposed ...
- PAT甲级——1130 Infix Expression (25 分)
1130 Infix Expression (25 分)(找规律.中序遍历) 我是先在CSDN上面发表的这篇文章https://blog.csdn.net/weixin_44385565/articl ...
- PAT 甲级 1074 Reversing Linked List (25 分)(链表部分逆置,结合使用双端队列和栈,其实使用vector更简单呐)
1074 Reversing Linked List (25 分) Given a constant K and a singly linked list L, you are supposed ...
- PAT 甲级 1086 Tree Traversals Again (25分)(先序中序链表建树,求后序)***重点复习
1086 Tree Traversals Again (25分) An inorder binary tree traversal can be implemented in a non-recu ...
- PAT 甲级 1062 Talent and Virtue (25 分)(简单,结构体排序)
1062 Talent and Virtue (25 分) About 900 years ago, a Chinese philosopher Sima Guang wrote a histor ...
- PAT 甲级 1060 Are They Equal (25 分)(科学计数法,接连做了2天,考虑要全面,坑点多,真麻烦)
1060 Are They Equal (25 分) If a machine can save only 3 significant digits, the float numbers 1230 ...
- PAT 甲级 1056 Mice and Rice (25 分) (队列,读不懂题,读懂了一遍过)
1056 Mice and Rice (25 分) Mice and Rice is the name of a programming contest in which each program ...
随机推荐
- C++ 实例练习-替换原生数组
C++ 实例练习-替换原生数组 main.cpp #include <stdio.h> #include "intarray.h" int main(int argc, ...
- LocalDate和LocalTime的用法介绍
原文:LocalDate和LocalTime的用法介绍 在JAVA中,常用的处理日期和时间的类主要有Date,Calendar,而在JDK1.8中,新增了两个处理日期和时间的类,一个是LocalDat ...
- iterations 快捷键
原帖:https://blog.csdn.net/Soinice/article/details/83505198 为了防止删除备份的. iterations 快捷键 Live Templates 其 ...
- JSON.toJSONString(Object object,SerializerFeature...features)详解
D package myProject; import java.math.BigDecimal; import java.util.ArrayList; import java.util.List; ...
- layui之普通数据表格显示switch选择表单组件
先看效果: 一般这写什么switch组件,下拉框组件只在表单显示,如果要在其他地方显示就要注意一下细节 默默跳槽一下这个layui,真的蛋疼,每次用它东西都要各种设置东西,无语 接下来看下代码: HT ...
- clippingNode 裁剪
let stencil = new cc.Sprite(fileName); let clippingNode = new cc.ClippingNode();this.addChild(clippi ...
- 在Linux系统上安装Jenkins
1.首先准备安装java环境,安装jdk 详情查看博客以,这里不做多介绍. 2.下载Jenkins至Linux服务器 查看内核版本信息:cat /proc/version uname -m cat / ...
- AcWing 900. 整数划分
#include <iostream> #include <algorithm> using namespace std; , mod = 1e9 + ; int n; int ...
- span标签间距
最近在做的一个项目里面碰到这么一个问题: <p> <span>块1</span> <span>块2</span> </p> 在“ ...
- java程序员摸爬滚打的三年,这些经历你值得借鉴
不知不觉都2020年2月底了,小羊同学从毕业快开始都一直从事java开发这个行业,前两天开通了头条号,想借此发文分享一下这几年的经历吧,如果你是还没毕业的大学生或者刚入行不久,也许会对你有帮助. 1: ...