题意:

输入一行由大写字母'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 分)的更多相关文章

  1. PAT甲级——1093 Count PAT's (逻辑类型的题目)

    本文同步发布在CSDN:https://blog.csdn.net/weixin_44385565/article/details/93389073 1093 Count PAT's (25 分)   ...

  2. PAT甲级 1093 Count PAT‘s (25 分) 状态机解法

    题目 原题链接 The string APPAPT contains two PAT's as substrings. The first one is formed by the 2nd, the ...

  3. PAT 甲级 1040 Longest Symmetric String (25 分)(字符串最长对称字串,遍历)

    1040 Longest Symmetric String (25 分)   Given a string, you are supposed to output the length of the ...

  4. PAT 甲级 1083 List Grades (25 分)

    1083 List Grades (25 分) Given a list of N student records with name, ID and grade. You are supposed ...

  5. PAT甲级——1130 Infix Expression (25 分)

    1130 Infix Expression (25 分)(找规律.中序遍历) 我是先在CSDN上面发表的这篇文章https://blog.csdn.net/weixin_44385565/articl ...

  6. 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 ...

  7. PAT 甲级 1086 Tree Traversals Again (25分)(先序中序链表建树,求后序)***重点复习

    1086 Tree Traversals Again (25分)   An inorder binary tree traversal can be implemented in a non-recu ...

  8. PAT 甲级 1062 Talent and Virtue (25 分)(简单,结构体排序)

    1062 Talent and Virtue (25 分)   About 900 years ago, a Chinese philosopher Sima Guang wrote a histor ...

  9. 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 ...

  10. 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 ...

随机推荐

  1. linux做免密登录,成功分发公钥后登录主机依旧需要输入密码的问题解决

    问题描述 在主机A上用ssh-keygen生成密钥对后,用ssh-copy-id命令将公钥成功copy到主机B上后,测试从A免密登录B,但是依旧需要输入主机B的密码后才能登录. 出现此错误的原因 如果 ...

  2. AndroidBDMap学习01:基于百度地图SDK的配置以及利用API实现一个简单的地图应用

    (一)注册并获取AK码: step1:找到keytool工具,并转移到.android目录下.(前提是已经安装了java jre/jdk)  为避免有些情况,在控制台无法找到keytool,可以把与k ...

  3. Docker+JMeter单机版+File Browser

    基于JMeter5.1.1+File Browser2.1.0  JMeter发起压测  File Browser作为文件服务器 一.目录结构: Dockerfile文件: FROM ubuntu:1 ...

  4. java中成员变量,局部变量,静态变量的辨析

    转自百度:https://baijiahao.baidu.com/s?id=1625360816541592483&wfr=spider&for=pc 1.java中成员变量,局部变量 ...

  5. EF database first

    https://www.cnblogs.com/net064/p/8024150.html 1.EF简介ADO.NET Entity Framework 是微软以 ADO.NET 为基础所发展出来的对 ...

  6. js面向过程 分页功能

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  7. 让ul li 或者table 进行循环往上滚屏

    转载:https://blog.csdn.net/u012138137/article/details/80729789 <div style="display:inline" ...

  8. Lenet 神经网络-实现篇(1)

    Lenet 神经网络结构为: ①输入为 32*32*1 的图片大小,为单通道的输入: ②进行卷积,卷积核大小为 5*5*1,个数为 6,步长为 1,非全零填充模式: ③将卷积结果通过非线性激活函数: ...

  9. Java进阶学习(4)之继承与多态(上)

    继承 媒体资料库的设计 代码复制是质量不良的表现 不具有可扩展性和可维护性 继承 子类父类关系 子类继承了什么 先定义初始化,后构造器 子类和父类的关系 子类有变量和父类变量相同时,父类变量隐藏 父类 ...

  10. Python3.6打开EAIDK-610开发板(计算机通用)摄像头拍照并保存

    环境:python3.6 代码: import cv2 import os output_dir ='/home/openailab/Desktop/huahui/came/' i = cap = c ...