题意:

输入一行由大写字母'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. SQL Server 2008创建数据库

    1.数据.数据库.数据管理系统基本概念: 数据:人类有用信息的符号化表示. 数据库:按照数据结构来组织.存储和管理数据的一个仓库. 数据库管理系统(DBMS):可维护.存储并为应用系统提供数据的软件系 ...

  2. lvm磁盘扩容

    LVM实现新挂载磁盘扩容到原有目录 #查看磁盘 fdisk -l #创建pv pvcreate /dev/sdb [root@VM-67-49 ~]# pvcreate /dev/sdb Physic ...

  3. Pyarm的Pyqt的配置

    相关连接: Python PyQt 安装python3.4 x64到c盘根目录. 安装PyQt5-5.5.1-gpl-Py3.4-Qt5.5.1-x64.exe 安装pycharm-professio ...

  4. LOJ 劳孙肉饼

    题目链接 XRRRRQAQ 去学文化的的样子太萌啦!!! XRRRRQAQ 在课上太无聊,以至于吃起了劳孙(你不用知道这是什么) 显然劳孙是一个 N * M 的肉饼(即N行 M 列) XRRRRQAQ ...

  5. Python爬取ithome的一所有新闻标题评论数及其他一些信息并存入Excel中。

    # coding=utf-8 import numpy as np import pandas as pd import sys from selenium import webdriver impo ...

  6. spring面试合集

    Spring是一个开源的轻量级Java SE / Java EE开发应用框架.在传统应用程序开发中,一个完整的应用是由一组相互协作的对象组成.所以开发一个应用除了要开发业务逻辑之外,最多的是关注如何使 ...

  7. CentOS之service iptables stop 显示not loaded

    停止firewalld服务停止防火墙,并禁用这个服务 sudo systemctl stop firewalld.servicesudo systemctl disable firewalld.ser ...

  8. 用python实现密码校验程序

    密码需要符合下面的要求: 8个字符以上,包含数字,大小写,开头不能为特殊字符. #! /usr/bin/pythonimport re password = str(input()) def lenO ...

  9. LED Decorative Light Manufacturer - Led Wall Lamp Performance Characteristics

    LED Decorative Light Manufacturer    introduction: LED wall lamp is a light-emitting diode as a ligh ...

  10. sourcetree(mac)设置代理

    Mercurial: edit ~/.hgrcas shown here: http://www.selenic.com/mercurial/hgrc.5.html#http-proxy Git: e ...