【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 ...
随机推荐
- JS高级---作用域,作用域链和预解析
作用域,作用域链和预解析 变量---->局部变量和全局变量, 作用域: 就是变量的使用范围 局部作用域和全局作用域 js中没有块级作用域---一对括号中定义的变量,这个变量可以在大括 ...
- 掩膜(mask)
1.掩膜(mask)的定义 用选定的图像,图形或物体,对处理的图像(全部或局部)进行遮挡,来控制图像处理的区域或处理过程.用于覆盖的特定图像或物体称为掩模或模板.光学图像处理中,掩模可以足胶片,滤光片 ...
- 新的存储网站,和存储单元dropbox
新的存储网站,和存储单元dropbox 待办 https://www.dropbox.com/home google 登陆 google邮箱 密码 521google 但是免费存储量只有2G goog ...
- 转:unittest的几种运行方式
#unittest-test.py import unittestfrom demo import RunMainimport HtmlTestRunner class TestMethod(unit ...
- 每天进步一点点------Allegro中Autosilk top, Silkscreen top 和Assembly top三个什么区别
Autosilk top:最后出gerber的时候,自动生成的丝印层.会自动调整丝印位置,以及碰到阻焊开窗的地方,丝印会自动消失,避免露锡的地方涂上丝印(一般画丝印层的时候,焊盘上不会画上丝印,所以过 ...
- 在电竞圈想摧枯拉朽的AI,到底能带来什么?
2019ChinaJoy,似乎并没有让这个暑期彻底燃动起来.在业界和玩家看来,2019ChinaJoy亮点匮乏.饱受诟病.不过细心观察的话,能够发现一个特殊现象--AI取代此前猎艳性质的cosplay ...
- linux虚拟机安装jenkins及maven/jdk配置
一.jenkins安装 (1)tomcat下载,下载地址:https://tomcat.apache.org 选择对应的版本,以下以新版的tomcat 9.0版本为例 下载zip包 (2)jenkin ...
- 《深入浅出WPF》学习总结之Binding
一.前言 友好的图形用户界面(Graphics User Interface ,GUI)的流行也就是近十来年的事情,之前应用程序与用户的交互是通过控制台界面(Console User Interfac ...
- ajax和promise及axios和promise的结合
链接:https://www.cnblogs.com/mmykdbc/p/10345108.html 链接2:https://blog.csdn.net/UtopiaOfArtoria/article ...
- JQuery中的DOM操作(转载)
原文链接:http://www.cnblogs.com/ILYljhl/archive/2013/07/10/3182414.html jQuery封装了大量DOM操作的API,极大提高了操作DOM节 ...