【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 ...
随机推荐
- Weighted Visibility Graph With Complex Network Features in the Detection of Epilepsy
Their data five data set, 100 single channel of EEG signals, each channel EEG has 4097 data point. t ...
- 嵌入式Linux学习---进程(1)
什么是一个进程?当用户敲入命令执行一个程序的时候,对系统而言,它将启动一个进程.但和程序不同的是,在这个进程中,系统可能需要再启动一个或多个进程来完成独立的多个任务.多进程编程的主要内容包括进程控制和 ...
- sql 单表操作
前戏 --创建表 create table xxx( id int unsigned not null auto_increment primary key, name varchar(20) not ...
- 未能加载文件或程序集“Autofac.Integration.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da”或它的某一个依赖项。找到的程序集清单定义与程序集引用不匹配。 (异常来自 HRESULT:0x80131040)
是因为web.config中dependentAssembly结点下的版本号和当前引用的程序集的版本号不一致!
- springboot11(springboot-redis)
一.Redis集群简介 1.RedisCluster概念 Redis的分布式解决方案,在3.0版本后推出的方案,有效地解决了Redis分布式的需求,当一个服务宕机可以快速的切换到另外一个服务.redi ...
- Failed to start mysqld.service: Unit not found
输入命令 systemctl start mysql.service 要启动MySQL数据库是却是这样的提示 Failed to start mysqld.service: Unit not foun ...
- eclipse debug启动时tomcat报错
Class.getDeclaredConstructors0(boolean) line: not available [native method] tomcat debug启动突然启动不起来 停 ...
- 【Python】 数字求和
# 用户输入数字 num1 = input('输入第一个数字:') num2 = input('输入第二个数字:') # 求和 sum = float(num1) + float(num2) # 显示 ...
- java基础(十)之向上转型/向下转型
向上转型:将子类的对象赋值给父类的引用. 向下转型:将父类的对象赋值给子类的引用. 向上转型 Student a = new Student(); Person zhang = a; 或者 Perso ...
- 【转载】C/C++内存管理详解
转自:http://chenqx.github.io/2014/09/25/Cpp-Memory-Management/ 内存管理是C++最令人切齿痛恨的问题,也是C++最有争议的问题,C++高手从中 ...